這是最近在mac上使用mysql workbench上遇到的一個小問題,仔細想了想其實這個問題本身就有毛病,論起正式環境來哪家公司是直接使用root去遠程登錄的呢?恐怕沒幾個,so不糾結root了創建一個新用戶用來遠程登陸mysql!網上一堆root遠程登陸MySql8.X的文章貌似都無法實現!
1.使用root登陸
[root@iZbp1gp76zixjk79d0yfaxZ ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 29
Server version: 8.0.13 MySQL Community Server - GPL
Copyright (c) 2000, 2018, 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 [(none)]>
2.創建新用戶
MySQL [(none)]> create user remote_user01;
Query OK, 0 rows affected (0.00 sec)
3.授權,這里測試給的權限比較大
MySQL [(none)]> GRANT ALL ON *.* TO 'remote_user01'@'%';
Query OK, 0 rows affected (0.01 sec)
4.更新密碼
MySQL [(none)]> ALTER USER 'remote_user01'@'%' IDENTIFIED WITH mysql_native_password BY 'remote_user01_password';
Query OK, 0 rows affected (0.00 sec)
5.刷新權限
MySQL [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)