CentOS 7 默认安装的是 MariaDB-5.5.68 或者 65。
查看版本的指令:
bashrpm -qa | grep mariadb
修改 yum 源的配置文件
bashvim /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
bashyum install mariadb-server -y
重新启动 mariadb 并设置开机自启
bashsystemctl start mariadb
systemctl enable mariadb
安装完之后建议运行一下安全初始化的动作:
bashmysql_secure_installation
编辑 MySQL 社区版的 yum 源
bashvim /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 安装
bashyum install mysql-community-server -y
启动 MySQL
bashsystemctl start mysqld
systemctl enable mysqld
查看 MySQL 5.7 初始密码
bashvim /var/log/mysqld.log
2021-10-11T01:58:56.929837Z 1 [Note] A temporary password is generated for
root@localhost: ps-->YUH95ri
登录 MySQL
bashmysql -uroot -p'ps-->YUH95ri'
安全初始化
bashmysql_secure_installation 复杂密码参考:123@qq.COM
本文作者:@Rrx
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!