1.停止mysql 服务,在cmd命令窗口中进入到mysql的安装bin目录,输入命令 net stop mysql
2.输入命令mysqld --skip-grant-tables 此时不能关闭命令窗口,重新打开一个新的命令窗口进入到mysql安装的bin目录
3.输入mysql 命令
4.mysql> use mysql
Database changed
mysql> insert into user set user='root',ssl_cipher='',x509_issuer='',x509_subject='';
(增加root用户的表)
Query OK, 1 row affected, 3 warnings (0.00 sec)
(这时可能会提示某字段如ssl_cipher无默认值, 只要加上,ssl_cipher=''; 其字段如有提示依次添加就OK了)
mysql> update user set Host='localhost',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',create_user_priv='y' where user='root';
(这里面是修改root用户的权限)
5.在任务管理器中 Ctrl+Shift+Esc 找到mysqld.exe进程把它删除掉
6.重新启动mysql 命令 net start mysql 就OK了!!!!!!!
--转自