新裝的 MySQL 一般會出現這樣的狀況:沒法遠程鏈接,可是本地鏈接是正常的.mysql
新裝的 MySQL 一般默認的用戶是 root, 而爲了安全起見, root 用戶是不容許遠程鏈接.sql
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.04 sec) 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> select user, host from user; +-----------+-----------+ | user | host | +-----------+-----------+ | mysql.sys | localhost | | root | localhost | +-----------+-----------+ 2 rows in set (0.00 sec)
# 新增用戶及密碼,並授予對應的權限 grant all privileges on yourDatabase.* to "yourUser"@"%" identified by "yourPassword"; # 刷新權限 flush privileges;