wget方式安装mysql
一、安装MySQL
1)下载rpm安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
2) 安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
3)检查mysql源是否安装成功
yum repolist enabled | grep "mysql.-community."

mysql-connectors-community/x86_64 MySQL Connectors Community
3> mysql-tools-community/x86_64 MySQL Tools Community
4> mysql57-community/x86_64 MySQL 5.7 Community Server
4)开始安装mysql
yum install mysql-community-server
yum install mysql-community-devel
5)启动mysql
service mysqld start
6)查看mysql启动状态
service mysqld status
7)设置开机启动
systemctl enable mysqld
systemctl daemon-reload
不开机启动
systemctl disable mysqld
8)获取mysql默认生成的密码
grep 'temporary password' /var/log/mysqld.log
2017-07-04T06:06:06.824762Z 1 [Note] A temporary password is generated for root@localhost: h8wob/ou+wpC
注意:密码就是结尾冒号后面那一串
进入mysql命令行
mysql -uroot -p
Enter password:h8wob/ou+wpC
如果成功进入mysql,linux前面的标识就会变成下面这种
mysql>
9)更换密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Mysql930125!';
注意:这里的新密码必须包含数字、小写或大写字母、特殊字符串。这个密码的复杂程度,和validate_password_policy的值有关。

至此,mysql安装完成

注意,需要修改user表的root记录的host字段 不然外部不允许访问本机
mysql> use mysql;
mysql> update user set host = '%' where user = 'root';
mysql> FLUSH PRIVILEGES; //回车使刚才的修改生效