命令记不住

登陆

mysql 给 root 开启远程访问权限

mysql给root开启远程访问权限

mysql给root开启远程访问权限

  • 通过shell登录到数据库中
  • 进入mysql库
[root@web01 ~]#mysql -uroot -pBgx123.com
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| wordpress          |
+--------------------+
5 rows in set (0.00 sec)
mysql> use mysql;
Reading table information for completion of table and column names
  • 新增root远程权限
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Bgx123.com';
Query OK, 0 rows affected, 1 warning (0.00 sec)
  • 从mysql数据库的grant表中重新加载权限数据
mysql> flush privileges; 
Query OK, 0 rows affected (0.00 sec)
mysql> 
  • 询用户表命令
mysql> select  User,authentication_string,Host from user;
+---------------+-------------------------------------------+-----------+
| User          | authentication_string                     | Host      |
+---------------+-------------------------------------------+-----------+
| root          | *4927A5B79C852EA2CE585A7679C5C26DF683F18C | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | localhost |
| mysql.sys     | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | localhost |
| root          | *4927A5B79C852EA2CE585A7679C5C26DF683F18C | %         |
+---------------+-------------------------------------------+-----------+
4 rows in set (0.00 sec)
mysql> 
推荐阅读