win7 MySql5.6.17
提示:1045accessdeniedforuser'root'@'localhost'usingpasswordyes
从网上找到的解决方法,以此博客做笔记记录。
Windows:
1.管理员登陆系统,停止MySQL服务或者结束mysqld-nt进程
2.进入命令行,来到mysql的安装目录.假设安装目录为d:\mysql\,CMD进入命令行
3.运行d:\mysql\bin\mysqld-nt--skip-grant-tables启动mysql,关闭权限的检查
4.运行d:\mysql\bin\mysqladmin-urootflush-privilegespassword"newpassword"重设root密码
5.重新启动mysql服务,net stop mysql接着net start mysql,然后mysql -u root -p 输入密码即可登录
这个验证成功,mysql运行重新正常
Linux系统方法一:
#/etc/init.d/mysqlstop
#mysqld_safe--user=mysql--skip-grant-tables--skip-networking&
#mysql-urootmysql
mysql>UPDATEuserSETPassword=PASSWORD(’newpassword’)whereUSER=’root’;
mysql>FLUSHPRIVILEGES;
mysql>quit
#/etc/init.d/mysqlrestart
#mysql-uroot-p
Enterpassword:<输入新设的密码newpassword>
mysql>方法二:
直接使用/etc/mysql/f文件中[client]节提供的用户名和密码:
#mysql-udebian-sys-maint-p
Enterpassword:<输入[client]节的密码>
mysql>UPDATEuserSETPassword=PASSWORD(’newpassword’)whereUSER=’root’;
mysql>FLUSHPRIVILEGES;
mysql>quit
#mysql-uroot-p
Enterpassword:<输入新设的密码newpassword>
mysql>