本文主要是介绍mysql root 修改密码 远程登陆,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
mysql root 修改密码
- 1,mysql root 修改密码
- 2,远程登陆
1,mysql root 修改密码
mysql> select Host,User,authentication_string,plugin from user;
+-----------+------------------+-------------------------------------------+-----------------------+
| Host | User | authentication_string | plugin |
+-----------+------------------+-------------------------------------------+-----------------------+
| localhost | root | | mysql_native_password |
| localhost | mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password |
| localhost | mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password |
| localhost | debian-sys-maint | *0FBB5154B34492EE36270AD02974EF7BB4685B21 | mysql_native_password |
+-----------+------------------+-------------------------------------------+-----------------------+
4 rows in set (0.00 sec)mysql> update user set host ="%" where user ="root";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0mysql> select Host,User,authentication_string,plugin from user;
+-----------+------------------+-------------------------------------------+-----------------------+
| Host | User | authentication_string | plugin |
+-----------+------------------+-------------------------------------------+-----------------------+
| % | root | | mysql_native_password |
| localhost | mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password |
| localhost | mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password |
| localhost | debian-sys-maint | *0FBB5154B34492EE36270AD02974EF7BB4685B21 | mysql_native_password |
+-----------+------------------+-------------------------------------------+-----------------------+
4 rows in set (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql> grant all on *.* to 'root'@'%';
Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> update user set authentication_string = PASSWORD('password_1234') where user = "root";
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1mysql> select Host,User,authentication_string,plugin from user;
+-----------+------------------+-------------------------------------------+-----------------------+
| Host | User | authentication_string | plugin |
+-----------+------------------+-------------------------------------------+-----------------------+
| % | root | *DAC80F3044BB947F9C6DEED74906CDFD9F9BD632 | mysql_native_password |
| localhost | mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password |
| localhost | mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password |
| localhost | debian-sys-maint | *0FBB5154B34492EE36270AD02974EF7BB4685B21 | mysql_native_password |
+-----------+------------------+-------------------------------------------+-----------------------+
4 rows in set (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
2,远程登陆
vim /etc/mysql/mysql.conf.d/mysqld.cnf
注释bind-address
#bind-address = 127.0.0.1
- 重启mysql
# /etc/init.d/mysql restart
- 解决远程连接报错
ERROR 2003 (HY000): Can't connect to MySQL server on
参考
- Reset a MySQL root password
- Fix: ERROR 2003 (HY000): Can’t connect to MySQL server on ‘127.0.0.1’ (111)
这篇关于mysql root 修改密码 远程登陆的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!