Centos7安装数据库并修改数据库密码并使不同的密码

1.wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
2.sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
3.sudo yum install mysql-server
4.mysql -u root

1.select user,password, host from user;
+------+----------+-----------------------+
| user | password | host                  |
+------+----------+-----------------------+
| root |          | localhost             |
| root |          | localhost.localdomain |
| root |          | 127.0.0.1             |
| root |          | ::1                   |
|      |          | localhost             |
|      |          | localhost.localdomain |
+------+----------+-----------------------+
2.update user set password=password('123456') where user='root';
3.select user,password, host from user;
+------+-------------------------------------------+-----------------------+
| user | password                                  | host                  |
+------+-------------------------------------------+-----------------------+
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | localhost             |
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | localhost.localdomain |
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | 127.0.0.1             |
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | ::1                   |
|      |                                           | localhost             |
|      |                                           | localhost.localdomain |
+------+-------------------------------------------+-----------------------+
4.update user set host='%', password=password('123456') where user='root' and host='127.0.0.1';
5.select user,password, host from user;
+------+-------------------------------------------+-----------------------+
| user | password                                  | host                  |
+------+-------------------------------------------+-----------------------+
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | localhost             |
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | localhost.localdomain |
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | %                     |
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | ::1                   |
|      |                                           | localhost             |
|      |                                           | localhost.localdomain |
+------+-------------------------------------------+-----------------------+
6.update user set password=password('139xxyy@Jiabier.me') where user='root' and host='localhost';
7.select user,password,host from user;
+------+-------------------------------------------+-----------------------+
| user | password                                  | host                  |
+------+-------------------------------------------+-----------------------+
| root | *82488A482B372FA4963C94B544C4C69062FB0700 | localhost             |
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | localhost.localdomain |
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | %                     |
| root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | ::1                   |
|      |                                           | localhost             |
|      |                                           | localhost.localdomain |
+------+-------------------------------------------+-----------------------+
8.flush privileges;
同样的root帐号,但外网和localhost是不同的密码。