mysql連接1130錯(cuò)誤的解決辦法:1、用root用戶登錄mysql數(shù)據(jù)庫(kù);2、更改“mysql”數(shù)據(jù)庫(kù)里的“user”表里的“host”項(xiàng),然后從“l(fā)ocalhost”改為“%”;3、插入本地登錄的用戶;4、用update方式修改root密碼;5、退出MySQL,在配置文件中注釋“skip-grant-tables”,然后重啟mysql服務(wù)即可。
本教程操作環(huán)境:Windows10系統(tǒng)、mysql5.5版本、Dell G3電腦。
mysql連接1130錯(cuò)誤怎么辦?
連接MYSQL數(shù)據(jù)庫(kù),報(bào)1130錯(cuò)誤的解決方法
重裝MySQL(重裝之前要先檢查一下是不是已經(jīng)存在mysql服務(wù),如果存在,先把已有的mysql服務(wù)刪除),由于不知道重裝之前的root密碼,使用重裝之后的密碼連接Mysql數(shù)據(jù),總報(bào) ERROR 1130: host 'localhost' not allowed to connect to this MySQLserver,不能連接數(shù)據(jù)庫(kù),猜測(cè)用戶權(quán)限和密碼的問(wèn)題。
1、用root用戶登錄mysql數(shù)據(jù)庫(kù)
(1)停止MySQL服務(wù),執(zhí)行net stop mysql;
(2)在mysql的安裝路徑下找到配置文件my.ini,
找到[mysqld]
輸入:skip-grant-tables,保存
(3)重啟mysql服務(wù),net start mysql;
(4)執(zhí)行mysql -uroot -p,回車,再回車,即可進(jìn)入mysql數(shù)據(jù)庫(kù);
2、在本機(jī)登入mysql后,更改 “mysql” 數(shù)據(jù)庫(kù)里的 “user” 表里的 “host” 項(xiàng),從”localhost”改稱'%'。
mysql>use mysql;
查詢出數(shù)據(jù)庫(kù)的用戶名
mysql>select host,user,password from user;
把用戶表里面的host項(xiàng)改為“%”
mysql>update user set host = '%' where user ='root'; mysql>flush privileges; #刷新用戶權(quán)限表 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,'','');
此時(shí)本地連接的用戶localhost密碼為空
4、修改root密碼
用update方式修改root密碼正常
mysql> update user set password=password("123") where user="root"; mysql>flush privileges;
5、退出MySQL,在配置文件中注釋:skip-grant-tables,重啟mysql服務(wù)
6、本地重新連接mysql數(shù)據(jù)庫(kù),輸入修改后的密碼,連接成功
推薦學(xué)習(xí):《MySQL視頻教程》