1.检查系统是否已存在旧版MysqL,并卸载。
MysqL5.7安装包可以去官网下载https://dev.MysqL.com/downloads/repo/yum/
安装MysqL5.7,遇到选项输入y就行了。或者安装的时候添加 -y 参数
- # yum install MysqL57-community-release-el6-8.noarch.rpm
- # yum install MysqL-community-server
网络状况不好时需要耐心等待一会儿。
安装完成,启动MysqL
查看MysqL 密码
- # grep "password" /var/log/MysqLd.log
- 2017-03-16T14:39:00.743966Z 1 [Note] A temporary password is generated for root@localhost: F7u?yhf,#LR6
- 2017-03-16T14:39:06.760164Z 0 [Note] Execution of init_file '/var/lib/MysqL/install-validate-password-plugin.XkuhjP.sql' started.
- 2017-03-16T14:39:06.809413Z 0 [Note] Execution of init_file '/var/lib/MysqL/install-validate-password-plugin.XkuhjP.sql' ended.
- 2017-03-16T14:39:08.625174Z 0 [Note] Shutting down plugin 'sha256_password'
- 2017-03-16T14:39:08.625190Z 0 [Note] Shutting down plugin 'MysqL_native_password'
- 2017-03-16T14:39:13.324745Z 3 [Note] Access denied for user 'UNKNOWN_MysqL_USER'@'localhost' (using password: NO)
- # vim /etc/my.cnf
- skip-grant-tables=1
重启 msyql
- # MysqL -uroot
- Welcome to the MysqL monitor. Commands end with ; or \g.
- Your MysqL connection id is 5
- Server version: 5.7.17 MysqL Community Server (GPL)
- Copyright (c) 2000,2016,Oracle and/or its affiliates. All rights reserved.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- MysqL>
查看user表中的信息
- MysqL> select user,host,authentication_string from user;
- +-----------+-----------+-------------------------------------------+
- | user | host | authentication_string |
- +-----------+-----------+-------------------------------------------+
- | root | localhost | *39820588410CB0B7DDA4AD6595C19A92C7B52B52 |
- | MysqL.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
- +-----------+-----------+-------------------------------------------+
修改root@localhost 密码
- MysqL> update user set authentication_string=password('123456') where user='root' and host='localhost';
- Query OK,1 row affected,1 warning (0.05 sec)
- Rows matched: 1 Changed: 1 Warnings: 1
查看并退出控制台
- MysqL> select user,authentication_string from user;
- +-----------+-----------+-------------------------------------------+
- | user | host | authentication_string |
- +-----------+-----------+-------------------------------------------+
- | root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
- | MysqL.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
- +-----------+-----------+-------------------------------------------+
- 2 rows in set (0.01 sec)
- MysqL> exit;
- Bye
用新密码登录
- # MysqL -uroot -p
- Enter password:
输入密码,成功登录
- # MysqL -uroot -p
- Enter password:
- Welcome to the MysqL monitor. Commands end with ; or \g.
- Your MysqL connection id is 6
- Server version: 5.7.17 MysqL Community Server (GPL)
- Copyright (c) 2000,Oracle and/or its affiliates. All rights reserved.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- MysqL>
对安全无要求的测试场景可以设置skip-grant-tables=1,不然则注释skip-grant-tables
授予远程访问权限
出现以上问题可以刷新一下再执行
查看新添加的权限
- MysqL> select user,authentication_string from user;
- +-----------+-----------+-------------------------------------------+
- | user | host | authentication_string |
- +-----------+-----------+-------------------------------------------+
- | root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
- | MysqL.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
- | root | % | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
- +-----------+-----------+-------------------------------------------+
- 3 rows in set (0.01 sec)