2024-03-12
MySQL
00
请注意,本文编写于 116 天前,最后修改于 100 天前,其中某些信息可能已经过时。

目录

MySQL 更新
安装 MySQL 5.7 社区版

MySQL 更新

CentOS 7 默认安装的是 MariaDB-5.5.68 或者 65。

查看版本的指令:

bash
rpm -qa | grep mariadb

修改 yum 源的配置文件

bash
vim /etc/yum.repos.d/mariadb.repo i[mariadb] name=mariadb laster version baseurl=http://mirrors.tuna.tsinghua.edu.cn/mariadb/yum/10.6/centos7-amd64/ gpgcheck=0

yum 安装 mariadb

bash
yum install mariadb-server -y

重新启动 mariadb 并设置开机自启

bash
systemctl start mariadb systemctl enable mariadb

安装完之后建议运行一下安全初始化的动作:

bash
mysql_secure_installation

安装 MySQL 5.7 社区版

编辑 MySQL 社区版的 yum 源

bash
vim /etc/yum.repos.d/mysql-community.repo [mysql-connectors-community] name=MySQL Connectors Community baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-connectors-community-el7-$basearch/ enabled=1 gpgcheck=1 gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql [mysql-tools-community] name=MySQL Tools Community baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-tools-community-el7-$basearch/ enabled=1 gpgcheck=1 gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql [mysql-5.6-community] name=MySQL 5.6 Community Server baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.6-community-el7-$basearch/ enabled=1 gpgcheck=1 gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql [mysql-5.7-community] name=MySQL 5.7 Community Server baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-$basearch/ enabled=1 gpgcheck=1 gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql [mysql-8.0-community] name=MySQL 8.0 Community Server baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-8.0-community-el7-$basearch/ enabled=0 gpgcheck=1 gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql

yum 安装

bash
yum install mysql-community-server -y

启动 MySQL

bash
systemctl start mysqld systemctl enable mysqld

查看 MySQL 5.7 初始密码

bash
vim /var/log/mysqld.log 2021-10-11T01:58:56.929837Z 1 [Note] A temporary password is generated for root@localhost: ps-->YUH95ri

登录 MySQL

bash
mysql -uroot -p'ps-->YUH95ri'

安全初始化

bash
mysql_secure_installation 复杂密码参考:123@qq.COM
如果对你有用的话,可以打赏哦
打赏
ali pay
wechat pay

本文作者:@Rrx

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!