先看清楚所在目錄
1.於是在環境變量中添加E:\。。\MySQL\MySQL Server 5.1\bin;
2.win+R後運行cmd
3.在命令行中輸入taskkill /f /im mysqld.exe
4.在輸入mysqld --skip-grant-tables;
5.新開一個命令行,輸入mysql -u root;
6.可以使用select host,user,password from mysql.user 查看,不過密碼加密了
用update mysql.user set password=PASSWORD'新密碼' where user='root';
7.輸入quit
8.net stop mysql
9.net start mysql
另外,很好笑的,如果是誤刪了root用戶,則使用下面的語句創建root用戶:
insert into mysql.user set Host='localhost',User='root',Password=Password('111111'),select_priv='y', insert_priv='y',update_priv='y',
Alter_priv='y',delete_priv='y',create_priv='y',drop_priv='y',reload_priv='y',shutdown_priv='y',Process_priv='y',file_priv='y',grant_priv='y',References_priv='y',index_priv='y',create_user_priv='y',show_db_priv='y',super_priv='y',create_tmp_table_priv='y',Lock_tables_priv='y',execute_priv='y',repl_slave_priv='y',repl_client_priv='y',create_view_priv='y',show_view_priv='y',create_routine_priv='y',alter_routine_priv='y';
參考:http://www.jb51.net/article/27152.htm
http://www.jb51.net/article/38473.htm