mysql root 修改密码
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: 0
mysql> 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: 1
mysql> 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
参考
来源:CSDN
作者:mixboot
链接:https://blog.csdn.net/u010953692/article/details/104100571