本地ip為192.0.4.138嘹悼,遠(yuǎn)程訪問(wèn)是報(bào)錯(cuò)姐霍,如下:
ictester@ic-tester:~$ mysql --host 192.0.4.138 -u root -p12345
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1130 (HY000): Host '192.0.4.133' is not allowed to connect to this MySQL server
需要開(kāi)啟遠(yuǎn)程權(quán)限,
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12345';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
上述錯(cuò)誤是因?yàn)樵O(shè)置的密碼太簡(jiǎn)單了邮利,
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=4;
Query OK, 0 rows affected (0.00 sec)
然后再執(zhí)行:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12345';
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
此時(shí)遠(yuǎn)端可以正常訪問(wèn)了
mysql --host 192.0.4.138 -u root -p12345
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.27 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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.