1. 安装wget,部分系统没有自带wget需要手动安装
shell > yum install wget
2. 查看系统有没有安装mysql服务,如果有卸载安装的mysql服务
shell> yum list installed mysql*
shell> yum remove mysql*
3. 下载mysql的yum源
shell > wget http://dev.mysql.com/get/ mysql57-community-release-el7-9.noarch.rpm
4. 安装mysql的yum源
shell> yum install mysql57-community-release-el7-9.noarch.rpm
5. 安装mysql
shell> yum install mysql-community-server mysql-community-client
6. 启动mysql服务
shell> systermctl mysqld start
7. 查看mysql初始密码
shell> cat /var/log/mysqld.log |grep password
8. 使用默认密码登录mysql
shell> mysql -uroot -p
9. 修改mysql初始密码
mysql> use mysql;
mysql> UPDATE user SET password=password("新密码") WHERE user='root';
或者
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
10. 刷新权限表使之立即生效
mysql> flush privileges;
mysql> exit;
11. 开启mysql的远程登录(需要使用新密码登录)
mysql> use mysql;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
注:'%'代表任意地址都可登录,指定ip地址可以限制只能固定的ip登陆