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