登录MySQL时出现Access denied 错误提示

适用于忘记密码时,跳过权限认证
一.安装好mysql后,登录时提示Access denied

hadoop001:mysqladmin:/usr/local/mysql:>mysql -uroot -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

二.查看配置文件,将skip-grant-tables放在[mysqld]下面
skip-grant-tables的作用是跳过权限认证
skip-external-locking的作用是跳过外部锁定

[mysqld]
port            = 3306
socket          = /usr/local/mysql/data/mysql.sock
skip-grant-tables
skip-external-locking

三.重新启动服务或者关闭使用的crt、xshell

hadoop001:mysqladmin:/usr/local/mysql:>service mysql stop
Shutting down MySQL..                                           [  OK  ]
hadoop001:mysqladmin:/usr/local/mysql:>service mysql start
Shutting  MySQL..                                                   [  OK  ]

四.重新登录MySQL

hadoop001:mysqladmin:/usr/local/mysql:>mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.23-log MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

你可能感兴趣的:(登录MySQL时出现Access denied 错误提示)