1. 程式人生 > >Mysql報錯message from server: ERROR 1062 (23000):

Mysql報錯message from server: ERROR 1062 (23000):

tor bsp rim ble user slow_log dup slow topic

Mysql連接報錯:java.sql.SQLException:null,message from server:"Host '27,45,38,132' is not allowed to connect.

原因是:遠程服務器不允許你的java程序訪問它的數據庫。所以,我們要對遠程服務器進行設置,使它允許你進行連接。


工具sqldeveloper連接遠程的MySQL 數據庫時,配置連接信息,連接發生錯誤,提示:message from server: "Host '192.168.1.8' is not allowed to connect to this MySQL server

但是將IP地址改為localhost又能正常連接到MySQL數據庫。


臨時處理方案:

1、先用localhost方式連接到MySQL數據庫,然後使用MySQL自帶的數據庫mysql;

# mysql -u root -p
Enter password:          
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 971
Server version: 5.5.56-log Source distribution
Copyright (c) 2000, 2017, 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>
mysql> use mysql;
Database changed

mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
24 rows in set (0.00 sec)


2、執行:select host from user where user = 'root'; 發現,host的值就是localhost。

技術分享圖片

所以將它的值改掉:update user set host='%' where user = 'root';

技術分享圖片

ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' 不予理會

技術分享圖片


3、修改完成後,執行:flush privileges

將修改內容生效,再次配置時,用IP地址或者localhost 就都能正常連接到MySQL數據庫了。


Mysql報錯message from server: ERROR 1062 (23000):