標籤:
重裝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錯誤的解決方案