Win7系统连接Mysql提示Access denied for user root@localhost怎么办

如题所述

近日有不少用户到本站反馈说遇到这样一个问题,就是在连接Mysql的时候,提示Accessdeniedforuserroot@localhost,该怎么解决这样的问题呢,现在随小编一起来看看Win7系统连接Mysql提示Accessdeniedforuserroot@localhost的具体解决方法吧。
1、点击“开始”-“程序”-运行,以管理员的身份运行;
2、在命令行中输入 C:Documents and SettingsMMCe:,e盘为Mysql服务所在的盘符;
3、打开Mysql.bin目录,在命令行输入E:cd E:mysql-5.5.49-win32mysql-5.5.49-win32bin;
4、接着在命令行中输入 E:SERVERMySQL5122binmysqld defaults-file= E:mysql-5.5.49-win32mysql-5.5.49-win32 my.ini console skip-grant-tables,只要出现下面信息,就说明 MySQL 已经起来了。
Version: 5.1.22-rc-community socket: port: 3306 MySQL Community Server
5、紧接着,不关闭此命令行窗口,重新打开一个命令行窗口,同样切到 “mysqlbin”目录下,然后执行下面的命令:
C:Documents and SettingsMMCe:
E:cd E:mysql-5.5.49-win32mysql-5.5.49-win32bin
D:cd D:SERVERMySQL5122bin E:SERVERMySQL5122binmysql -u root mysql
出现Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 1Server version: 5.1.22-rc-community MySQL Community Server (GPL)Type help; or h for help. Type c to clear the buffer.mysql
6、接着在命令行中输入粗体命令:
mysqlUPDATE user SET Password=PASSWORD(mynewpass) where USER=root;
Query OK, 2 rows affected (0.05 sec) Rows matched: 2 Changed: 2 Warnings: 0 mysqlFLUSH PRIVILEGES; Query OK, 0 rows affected (0.02 sec) mysqlquit Bye
7、好了到此步,可以关闭第一个 DOS 窗口了。打开系统服务控制窗口(控制面板管理工具服务),启动 MySQL 服务。
8、在剩下的第二个 DOS 窗口中,用新的 ROOT 密码连接 MySQL。
D:SERVERMySQL5122binmysql -u root -p Enter password:******** Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 2 Server version: 5.1.22-rc-community MySQL Community Server (GPL) Type help; or h for help. Type c to clear the buffer.
9、mysqlquit Bye 至此,系统恢复 ROOT 用户管理权限完成。
温馨提示:答案为网友推荐,仅供参考
大家正在搜