Linux CentOS 7下RPM包安装MySQL5.7

一、搭建环境

主(Master) :192.168.199.103
从(Slave) :192.168.199.23

[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core)

MySQL版本:Server version: 5.7.24 MySQL Community Server (GPL)
学习环境下最好关闭防火墙:https://blog.csdn.net/qq_39680564/article/details/84940221

卸载自带的Mariadb

yum -y remove mariadb-libs

下载mysql-5.7.27

yum install -y wget
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar
tar -xvf mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar

安装mysql-5.7.27

yum install -y libaio net-tools perl \ 
&& rpm -ivh mysql-community-common-5.7.27-1.el7.x86_64.rpm \
&& rpm -ivh mysql-community-libs-5.7.27-1.el7.x86_64.rpm \
&& rpm -ivh mysql-community-client-5.7.27-1.el7.x86_64.rpm \
&& rpm -ivh mysql-community-server-5.7.27-1.el7.x86_64.rpm \
&& rpm -ivh mysql-community-libs-compat-5.7.27-1.el7.x86_64.rpm

启动并设置开机自启

systemctl start mysqld && systemctl enable mysqld

获取初始密码

grep password /var/log/mysqld.log | sed 's/.*\(............\)$/\1/'

进入MySQL命令行,修改密码,设置访问权限

[root@localhost ~]# mysql -uroot -p 
Enter password: 

mysql> set password for root@localhost = password('123456Aa.');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> grant all privileges on *.* to 'root'@'%' identified by '123456Aa.';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
发布了146 篇原创文章 · 获赞 25 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_39680564/article/details/103696926