Solve the Problem of MySQL error 1045 (28000): Access denied for user 'root' @ 'localhost '.

Source: Internet
Author: User
Error 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: No) on Red Hat Enterprise Linux 5 Server MySQL startup error: Error 1045 (28000 ): access denied for user 'root' @ 'localhost' (using password: No)
Cause 1-startup command error:
When I started, I directly entered the command: MySQL start
The correct startup command is:/etc/rc. d/init. d/MySQL start

Cause 2-configuration file error:
Check my. CnF in etc as follows: [client]
# Password = your_password
Port = 3306
Socket =/usr/MySQL-data/MySQL. Sock
# Here follows entries for some specific programs
# The MySQL Server
[Mysqld]
Port = 3306
Socket =/usr/MySQL-data/MySQL. Sock

Cause 3-Startup File error:
You need to modify the MySQL STARTUP script/etc/rc. d/init. d/MySQL,
Where datadir =? Check one row!

Cause 4-The premise is that you report an error when using PHP connection!
In/etc/PHP. ini, modify the mysql. default_socket value:
MySQL. default_socket =/var/lib/MySQL. Sock
Return to the terminal and set a connection: ln-S/var/lib/MySQL. Sock/tmp/MySQL. Sock
(In the/etc/PHP. ini file mysql. default_socket, the description of the mysql. default_socket value is as follows,
; Default socket name for local MySQL connects. If empty, uses the built-in MySQL defaults.
This value is blank at the beginning, that is, if we do not take the initiative to modify it, PHP will use the default value built in MySQL)

Another article: MySQL error 1045 (28000): Access denied for user 'root' @ 'localhost'

To solve this problem, you need to force a new password. The method is as follows:

/Etc/init. d/MySQL stop (Service mysqld stop)
/Usr/bin/mysqld_safe -- skip-grant-tables
Enable another SSH connection
[Root @ localhost ~] # MySQL
Mysql> use MySQL
Mysql> Update user SET Password = PASSWORD ("123456") where user = "root ";
Mysql> flush privileges;
Mysql> exit

Pkill-kill-T pts/0: force the ** users whose PTS is 0 (the user window before mysqld_safe is run) out.
Start MySQL normally:/etc/init. d/MySQL start (Service mysqld start)

Note: In addition, service MySQL star is required to start service MySQL stop before it can be stopped.
The command cannot be found directly using MySQL. The error is "Bash: mysql: Command not found". You can run the command directly in the bin folder and absolute path in the MySQL installation directory, also need to add. /MySQL can be executed.This article comes from:Http://sundful.javaeye.com/blog/704337Another article about clearing passwords and resetting users:

Quote:
First things first. log in as root and stop the MySQL daemon.

Sudo/etc/init. d/MySQL stop

Now lets start up the MySQL daemon and skip the grant tables which store the passwords.

Sudo mysqld_safe -- skip-grant-tables &

(Press Ctrl + C now to disown the process and start typing commands again)

You shoshould see mysqld start up successfully. If not, well you have bigger issues. Now you shoshould be able to connect to MySQL without a password.

Sudo MySQL -- user = root MySQL

Update user SET Password = PASSWORD ('new-password ');
Flush privileges;
Exit;

Now kill your running mysqld then restart it normally.

Sudo killall mysqld_safe &
(Press Ctrl + C now to disown the process and start typing commands again)
/Etc/init. d/MySQL start

You shoshould be good to go. Try not to forget your password again.

Http://www.howtoforge.com/reset-forgotten-mysql-root-password In addition, Summary of denied: MySQL authentication deni_3/29/2005, AM

It seems to me that a lot of people have auth denial when trying to make connections to MySQL. they seem to ignore the text of the error message. 'Access denied 'means access denied, nothing else.

Remember three things have to match. the host as MySQL sees it, the username, And the password. when MySQL returns Access Denied it's not broken. one or more of those three things does not match. I don't really need to reiterate what's in the manual. chang the lock or change the key to make it fit.

The document connecting to MySQL here is: http://dev.mysql.com/doc/refman/5.5/en/access-denied.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.