1、下载包:
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
2、安装软件源:
sudo rpm -Uvh mysql57-community-release-el7-10.noarch.rpm
3、安装mysql服务端:
yum install -y mysql-community-server
4、启动mysql:
service mysqld start
5、查看运行状态:
service mysqld status
6、此时mysql有初始密码,需要密码才可登录,获取初始密码语句如下:
grep 'temporary password' /var/log/mysqld.log
会获取如上语句,其中 apTl,rdwK2?T 即为密码。
7、登录mysql
mysql -uroot -papTl,rdwK2?T
8、
修改密码,不改密码直接执行sql会报错:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'mypass';
9、上面修改的密码因为太简单报错,可修改如下参数使密码可以设置简单:
set global validate_password_policy=0;
set global validate_password_length=1;
再次修改简单的密码就可
ALTER USER 'root'@'localhost' IDENTIFIED BY 'mypass';
10、允许其他机器可以登录:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypass' WITH GRANT OPTION;
FLUSH PRIVILEGES;