問題緣由:mysql服務器出於安全考慮,默認只容許本地登陸數據庫服務器。mysql
問題解決:登入mysql後,更改 "mysql" 數據庫裏的 "user" 表裏的 "host" 項,從"localhost"改稱"%",而後重啓mysql這樣就容許全部的遠程機器進行訪問了。sql
1. 修改MySQL 配置文件數據庫
bind-address = 10.216.x.x //網卡IP
2. 修改mysql 表安全
root@cdndev:/share/test# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 40 Server version: 5.5.62-0+deb8u1 (Debian) 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | lovely_cdn | | mysql | | performance_schema | +--------------------+ 4 rows in set (0.00 sec)
mysql> use mysql; Database changed mysql> select * from user; +-----------+------------------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+--------+-----------------------+ | Host | User | Password | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | Create_tablespace_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections | plugin | authentication_string | +-----------+------------------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+--------+-----------------------+
mysql> UPDATE user set Host='%' WHERE User='root' -> ; ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
3. 重啓mysql服務器
/etc/init.d/mysql restart
ide
4. 使用Navicat 鏈接該數據庫okspa