windows下本地或者遠端連線MYSQL資料庫,報1130錯誤的解決方案

來源:互聯網
上載者:User

標籤:

重裝MySQL,由於不知道重裝之前的root密碼,使用重裝之後的密碼串連Mysql資料,總報 ERROR 1130: host ‘localhost‘ not allowed to connect to this MySQLserver,不能串連資料庫,猜測使用者權限和密碼的問題。

1、用root使用者登入mysql資料庫

(1)停止MySQL服務,執行net stop mysql;

(2)在mysql的安裝路徑下找到設定檔my.ini,

   找到[mysqld]
   輸入:skip-grant-tables,儲存

(3)重啟mysql服務,net start mysql;

(4)執行mysql -uroot -p,斷行符號,再斷行符號,即可進入mysql資料庫;

 

2、在本機登入mysql後,更改 “mysql” 資料庫裡的 “user” 表裡的 “host” 項,從”localhost”改稱‘%‘。

mysql>use mysql;

mysql>select host,user,password from user;

mysql>update user set host = ‘%‘ where user =‘root‘;

mysql>flush privileges;    #重新整理使用者權限表

mysql>select host,user,password  from user where user=‘root‘;

 

3、插入本地登入的使用者

mysql>insert into user values(‘localhost‘, ‘root‘, ‘‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘, ‘Y‘,‘‘,‘‘,‘‘,‘‘,0,0,0,0,‘‘,‘‘);

此時本地串連的使用者localhost密碼為空白

 

4、修改root密碼

(1)用set password 方式修改root密碼遇到錯誤ERROR 1290 (HY000)

mysql> set password for [email protected]‘localhost‘=PASSWORD(‘12345‘);
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot exe
cute this statement

(2)用update方式修改root密碼正常

mysql> update user set password=password("123") where user="root";

mysql>flush privileges;

 

5、退出MySQL,在設定檔中登出:skip-grant-tables,重啟mysql服務

6、本地重新串連mysql資料庫,輸入修改後的密碼,串連成功

 

windows下本地或者遠端連線MYSQL資料庫,報1130錯誤的解決方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.