(1) 中止Mysql服務mysql
(2)Mysql安裝目錄中找到 【my.ini】配置文件,找到 sql
datadir="C:/ProgramData/MySQL/MySQL Server 5.5/Data/" spa
相似的路徑,關鍵在datadir,後面是我本機的路徑能夠忽略,改成你修改後的存儲路徑如:命令行
datadir="D:/mysql5.5/data/",必須保證此目錄存在,否則啓動服務時會報1067進程意外終止錯誤。code
並在 my.ini 文件 添加 skip-grant-tables=true 配置。server
(3) 從新啓動Mysql服務,嘗試鏈接可能會出現 :進程
Access denied for user 'root'@'localhost' (using password: Yes)ip
此時須要修改下root用戶的密碼,操做以下input
(4) 命令行進入 mysql 安裝目錄 bin/ 下 ,按下面的順序依次輸入命令 it
C:\Users\Administrator>cd D:\mysql5.5\bin
C:\Users\Administrator>d:
D:\mysql5.5\bin>mysql -uroot 或執行命令 mysql -u root -p
注意:mysql -uroot 出現 Access denied for user 'root'@'localhost' (using password: Yes)錯誤嘗試使用 mysql -u root -p 命令
mysql> use mysql;
mysql> UPDATE user SET Password=PASSWORD('root') where USER='root';
mysql> FLUSH PRIVILEGES;
其餘用戶也參考root設置方法重置密碼。
--至此設置完成,能夠嘗試用密碼鏈接,命令以下:
D:\dsserver\mysql5.5\bin>mysql -uroot -p
Enter password: ****
輸入密碼後,出現如下信息說明鏈接成功:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.5.19 MySQL Community Server (GPL) Copyright (c) 2000, 2011, 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>
(5) 其餘用戶添加設置前,須要從mysql.user表刪除主機爲localhost user 爲空的數據
(6)而後 刪除 my.ini 文件 添加 skip-grant-tables=true 的 配置,重啓服務。
而後用其餘用戶嘗試登陸
有時候大的插入和更新會被max_allowed_packet 參數限制掉,致使失敗,可在my.ini配置以下參數
max_allowed_packet=100M