MySQL Access denied for user Root@localhost Error Resolution summary (GO)

Source: Internet
Author: User
Tags mysql in

MySQL Access denied for user[email protected]Summary of error resolution (GO)

MySQL Access denied for user \ ' root\ ' @\ ' localhost\ ' "solution Summary, below we have a common occurrence of some error code analysis and give a solution, the need for friends to refer to.

Error code 1045

Access denied for user ' root ' @ ' localhost ' (using Password:yes)

The workaround is to reset the root user password by following the steps in the Windows platform:
1. Log in to the system as a system administrator;
2. If the MySQL server is running, stop it.
If the server is running as a Windows service, go to Service Manager: Start menu, Control Panel, management tools, services
If the server is not running as a service, you might need to use Task Manager to force it to stop.
3. Create 1 text files and place the following commands in a single line:
SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' Mynewpassword ');
Save the file with any name. In this case, the file is C:mysql-init.txt.
4. Enter DOS command prompt: Start menu, run-cmd
Assume that you have installed MySQL to C:mysql. If you installed MySQL in a different location, please adjust the following commands accordingly.
At the DOS command prompt, execute the command:
C:> c:mysqlbinmysqld-nt--init-file=c:mysql-init.txt
When the server starts, change the root user password by executing the contents of the file named by the "--init-file" option (function: Read the SQL command from the specified file at startup). When the server starts successfully, you should remove C:mysql-init.txt.
5. Stop the MySQL server and restart it in normal mode. If you are running the server as a service, you should start it from the Windows Services window. If you start the server manually, you can use the command as you normally would.
You should be able to connect using the new password.


My system is Ubuntu6.06, and recently installed MySQL in the MySQL tool, there are always error prompts:

# mysql-uroot-p
Enter Password:
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)

Use the Web-based method to modify the root user's password:

# mysqladmin-uroot-p password ' newpassword ' Enter password:mysqladmin:connect to server at ' localhost ' failederror: ' ACC ESS denied for user ' root ' @ ' localhost ' (using Password:yes) '

Now I finally found the solution, as follows (please test method Three first, thank you!) ):

Method One:

#/etc/init.d/mysql stop# mysqld_safe--user=mysql--skip-grant-tables--skip-networking, mysql-u root mysqlmysql& Gt UPDATE user SET Password=password (' NewPassword ') where user= ' root ';mysql> FLUSH privileges;mysql> quit#/etc/ Init.d/mysql restart# mysql-uroot-penter Password: < Enter the new password newpassword>

Another article about Linux errors


MySQL boot error on Red Hat Enterprise Linux 5 server: Error 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)
Cause 1-Startup command error:
I started by typing the command directly: MySQL start
The correct startup command is:
/etc/rc.d/init.d/mysql start

Cause 2-Configuration file Error:
Check etc below the MY.CNF below:

[Client]

#password   = Your_passwordport =     3306socket     =/usr/mysql-data/mysql.sock# Here follows entries for some Specific programs# the MySQL server[mysqld]port     = 3306socket     =/usr/mysql-data/mysql.sock

Cause 3-Startup file error:
Need to modify MySQL startup script/etc/rc.d/init.d/mysql,
where datadir=? Check the line!

Cause 4-If you have an error when using PHP connection!
In/etc/php.ini, modify the value of the Mysql.default_socket setting to:
Mysql.default_socket=/var/lib/mysql/mysql.sock
Back to finish setting up a connection: Ln-s/var/lib/mysql/mysql.sock/tmp/mysql.sock
(in/etc/php.ini mysql.default_socket this file, the description of the value of Mysql.default_socket is this,
;D efault socket name for local MySQL connects. If empty, uses the built-in MySQL defaults.
This value is empty at first, that is, PHP will use the default value built in MySQL if we do not take the initiative to modify it.


Note: You also encounter the need to service MySQL star in order to start service MySQL stop to stop.
There is also the direct use of MySQL can not find the command, the error is "Bash:mysql:command not found" can be directly **mysql the Bin folder in the installation directory with the absolute path to run commands, and some need to add./mysql to execute.

There are several ways to change the password in MySQL

Method One

Using phpMyAdmin

(graphical management of MySQL database Tools), this is the simplest, directly with the SQL statement to modify the MySQL Database Library user table, but do not forget to use the password function, insert the user with the Insert command, modify the user with the update command, delete with delete command. A detailed description of the data table User field is later in this section.

Method Two

Use Mysqladmin. Input

Mysqladmin-u root-p OldPassword newpasswd

After executing this command, you need to enter the root's original password so that the root password will be changed to NEWPASSWD. Similarly, you can change your password by changing the root of the command to your username.

Of course, if your mysqladmin isn't connected to MySQL,

Server, or you have no way to execute mysqladmin, then this method is invalid, and mysqladmin cannot erase the password.

The following methods are used at the MySQL prompt and must have root privileges for MySQL:

Method Three

Mysql> INSERT into Mysql.user (Host,user,password) VALUES ('% ', ' system ', Password (' manager '));

Mysql> FLUSH Privileges

Specifically, this is the addition of a user named system with a password of manager. Note To use the password function, and then use the flush

Privileges to perform the confirmation.

MySQL Access denied for user [email protected] Error resolution summary (GO)

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.