shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
shell> yum localinstall mysql57-community-release-el7-11.noarch.rpm
shell> yum install mysql-community-server
shell> systemctl start mysqld
shell> systemctl enable mysqld shell> systemctl daemon-reload
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。
grep 'temporary password' /var/log/mysqld.log
通过下面的方式找到root默认密码,然后登录mysql进行修改
shell> mysql -u root -p --输入查找的密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'M$Fa!SN5';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '*****' WITH GRANT OPTION; mysql> create user '用户名'@'%' identified by '密码'; FLUSH PRIVILEGES;刷新数据库
打开mysql配置文件vi /etc/mysql/mysql.conf.d/mysqld.cnf 将bind-address = 127.0.0.1注销
wget http://repo.mysql.com/mysql-apt-config_0.8.13-1_all.deb dpkg -i mysql-apt-config_0.8.13-1_all.deb apt update apt install mysql-server 安装完成后,其他设置相同