- 工信部備案號 滇ICP備05000110號-1
- 滇公安備案 滇53010302000111
- 增值電信業務經營許可證 B1.B2-20181647、滇B1.B2-20190004
- 云南互聯網協會理事單位
- 安全聯盟認證網站身份V標記
- 域名注冊服務機構許可:滇D3-20230001
- 代理域名注冊服務機構:新網數碼
重裝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 root@'localhost'=PASSWord('12345');
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
注意:以skip-grant-tables方式啟動mysql后,不能用直接用set password的方式修改root密碼,須注釋skip-grant-tables, 然后重啟服務,連接數據庫修改密碼
(2)用update方式修改root密碼正常
mysql> update user set password=password("123") where user="root";
mysql>flush privileges;
(3)不連接數據庫,直接在cmd下修改密碼
mysqladmin -uroot -p舊密碼 password 新密碼
此種方式修改密碼也不能在以“skip-grant-tables“方式啟動mysql后進行:
mysqladmin -uroot -p123456 password 1234
5、退出MySQL,在配置文件中注釋:skip-grant-tables,重啟mysql服務
6、本地重新連接mysql數據庫,輸入修改后的密碼,連接成功。
售前咨詢
售后咨詢
備案咨詢
二維碼
TOP