Complete the process of solving ERROR 1045 (28000): Access denied for user 'mysql' @ 'localhost' (using password: NO)

ERROR 1045 (28000): Access denied for user 'mysql' @ 'localhost' (using password: NO)
This issue mostly online around following the second step (to change the password) unfolded, very pit father is how I can not get landing (landing are various modes of failure), so what is it to change the password?
I distracted the whole step mysql log file summarizes the problem as follows:


The first step: modify path pid
view the log file:
 CAT /var/log/mysqld.log


2013-10-26 16:39:34 3712 [ERROR] / usr / sbin / mysqld: Can Not Create / Write to File '/var/run/mysqld/mysqld.pid': - (2 Errcode SUCH No File or Directory)
2013-10-26 16:39:34 3712 [ERROR] Can not start server: can not create PID file: no such file or directory


reasons:
MySQL user does not operate / var / run directory permissions, so the pid file can not be created, making it impossible to establish process information file, when landing on the landing process can not open, you can not log in.


Solution:
Modify /etc/my.conf
original
 # pid-file = / var / run / mysqld / mysqld.pid
amended as
pid-file = / var / lib / mysql / mysqlid.pid


Examination revealed, mysql user can not cd / var / run /. Mysql may have to modify the permissions of the directory and then execute mysql to enter the database.


Step Two: Modify database default password
/etc/init.d/mysql STOP (STOP mysqld-Service)
/ usr / bin / the mysqld_safe --skip-Grant-Tables
In addition to open SSH connection
[the root @ localhost ~] # MySQL
MySQL> MySQL use
MySQL> SET password = Update User password ( "123456") WHERE User = "the root";
MySQL> the flush privileges;
MySQL> Exit


then
[@ localhost MySQL etc] $ PS -A | grep MySQL
4532 PTS / 0 00: mysqld_safe 00:00
5542 PTS / 0 00:00:00 mysqld
[MySQL @ localhost etc] the kill -9 4532 5542 $ 
normal start MySQL: /etc/init.d/mysql start (service mysqld start )


The third step:
Log ok . mysql -uroot -p


/ ********************* The following is my complete repair process information, including the analysis process: *************** **************** /
myslq Status SUCCESS but various attempts can not afford to have landed effect
[MySQL @ localhost etc] $ MySQL Service Start
Starting MySQL. SUCCESS!
[MySQL @ localhost etc] MySQL-Service Status $
! SUCCESS running the MySQL (4463)
[MySQL @ localhost etc] $ -uroot-MySQL
ERROR 1045 (28000): User Access denied for 'the root' @ 'localhost' (the using password: NO)
[MySQL @ localhost etc] MySQL -umysql $
ERROR 1045 (28000): Access denied for the User 'MySQL' @ 'localhost' (a using password: NO)
[MySQL @ localhost etc] $ mysqladmin -p password-uroot-
the Enter password:
mysqladmin: Connect to Server AT ' localhost 'failed The
error:' Access denied for the User 'root' @ 'localhost' (using password: YES)'
I want to die with wood there! ! !
View Log cool bar ->
[MySQL @ localhost ~] $ CAT /var/log/mysqld.log 
2013-10-26 16:39:34 3712 [ERROR] / usr / sbin / mysqld: of Can not the Create / the Write File to '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No SUCH File or Directory)
2013-10-26 16:39:34 3712 [ERROR] of Can not Start Server: CAN not the Create PID file: No such file or directory
Nima! ! !
[mysql @ localhost ~] $ cd / var / RUN /
-bash: cd: / var / RUN /: enough authority
[mysql @ localhost ~] $ 
so be it! ! !
[MySQL @ localhost ~] $ CAT /etc/my.cnf
[mysqld]
DATADIR = / var / lib / MySQL
Socket = / var / lib / MySQL / mysql.sock
User MySQL =
#-symbolic links Disabling to Prevent Assorted IS Recommended Risks Security
symbolic-links = 0


[the mysqld_safe]
= error-log / var / log / mysqld.log
# File-PID = / var / RUN / mysqld / mysqld.pid
PID-File = / var / lib / MySQL / mysqlid.pid
restart MySQL
[MySQL @ localhost etc] $ STOP MySQL Service
Shutting Down MySQL .. SUCCESS!
[MySQL @ localhost etc] $ MySQL Service Start
Starting MySQL .. SUCCESS!
Nima ah! ! !
[mysql @ localhost etc] $ mysql
ERROR 1045 (28000): Access denied for the User 'mysql' @ 'localhost' (a using password: NO)
At this point, if you want to execute mysql direct landing, you need to do this
[mysql @ localhost etc ] $-Service MySQL STOP
! .. SUCCESS Shutting Down the MySQL 
[MySQL @ localhost etc] $ = MySQL the mysqld_safe --user Tables --skip-Grant---skip-Networking
[MySQL @ localhost ~] $ MySQL
the Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.14


Copyright (c) 2000, 2013, 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> 


但是要想在service mysql start方式下登陆继续往下看吧。
尼玛!!!
[mysql@localhost etc]$ mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[mysql@localhost ~]$ mysql
ERROR 1045 (28000): Access denied for user 'mysql' @ 'localhost' (using password: NO)
Explanation: This is because the database root password is not set the default result.
(The following is a search on the Web ERROR 1045 (28000): Access denied for user 'mysql' @ 'localhost' (using password: NO) all solution, but if
the path pid is not modified, there is simply landing not go in, what On the Change password because mysql has never been able to create is the root of the problem pid file).
this issue should force a re-modify the password, as follows:
/etc/init.d/mysql STOP (Service mysqld STOP)
/ usr / bin / mysqld_safe - skip-grant-tables
further open SSH connection
[the root @ localhost ~] # MySQL
MySQL> use MySQL
MySQL> Update User SET password = password ( "123456") WHERE User = "the root";
MySQL> the flush privileges;
MySQL> Exit


then
[@ localhost MySQL etc] $ PS -A | grep MySQL
4532 PTS / 0 00:00:

[mysql@localhost etc]$ kill -9 4532 5542 
正常启动 MySQL:/etc/init.d/mysql start   (service mysqld start)


终于!!!
[mysql@localhost ~]$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.14


Copyright (c) 2000, 2013, 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.
Published 90 original articles · won praise 21 · views 470 000 +

Guess you like

Origin blog.csdn.net/yx13649017813/article/details/43760775