MySQL 1045 Login failed (GO)

Source: Internet
Author: User

http://blog.csdn.net/bbirdsky/article/details/8134528#

When you log in to the MySQL database: Error1045 errors (such as), it indicates that you entered the user name or password error is denied access, the simplest solution is to uninstall and reload the MySQL database, But the disadvantage is that the information in the previous database will be lost, if you do not want to reload, then you need to retrieve the password or reset the password. There are a number of ways to solve this, and I recommend that you use a principle that is simple and easy to apply to windows and Linux platforms.  

MySQL 1045 Error

[Plain]View Plaincopy
    1. ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes)

Solution:

1, Stop the service: Stop the MySQL service;

2, Skip verification: Modify the MySQL installation directory under the my.ini configuration file, so that the login to skip permission checks;

3, Change Password: Start the MySQL service, log in to MySQL, at this time prompted to enter a password, enter any password return to enter MySQL. The root user's password is then modified by the SQL statement;

4. Restart the service: Delete or add #号注释 the Skip permission statement added to the My.ini file . Restart the service and log in with the modified password.

Windows System Specific actions:

1, Stop the service:

Method 1: Use the DOS command net stop MySQL to use this method , the MySQL service must be installed for the service, otherwise

The second method can be used when the service name is invalid.

Method 2: Go to "Control Panel"--"Administrative Tools" --"services", find the MySQL service, click on the left stop.

2. Skip Verification:

Go to MySQL installation path (take the default installation path for example)C:\Program files\mysql\mysql Server 5.1\, locate the my.ini configuration file (some file records MySQL general parameters, each start service will load this file first, in the my.ini configuration file on the last line to join Skip_grant_tables, this statement can ignore the login check.

3, change the password:

Start The MySQL service, enter the DOS environment, enter mysql-u root-p log in to MySQL (if the installation is not checked to add

Environment variables, you need to use the CD command to enter the MySQL installation directory, this time prompted to enter a password, enter any password entered MySQL, mysql> control, this indicates that the MySQL has been successfully logged ;

Mysql> usemysql (Switch the database to the MySQL library)

mysql> UPDATE user SET password=password (' newpswd ')WHERE user= ' root ' (change password)

The password function is the MySQL intrinsic, where newpswd is the modified new password.

4. Restart the service:

Remove or add #号注释 to the Skip permission statement that is added to the My.ini file . Restart the service and log in with the modified password.

Linux System specific operations:

1, Stop the service:

Execution:/etc/init.d/mysqlStop

(Your machine is not necessarily /etc/init.d/mysql or /etc/init.d/mysqld, and can be found through the Find command).

2. Skip Verification:

Execution:/usr/local/mysql/bin/mysqld_safe--skip-grant-tables >/dev/null 2>&1 &

(If the location of the mysqld_safe needs to be modified if it is not, you can find it with the Find command if it is unclear ).

3, change the password:

Perform:

/usr/local/mysql/bin/mysql-u root mysql (login to MySQL)

mysql> UPDATE userSET password=password (' newpswd ')WHERE user= ' root ' (Change password)

Mysql>flush Privileges ( refresh MySQL permissions related tables)

Mysql>exit (quit MySQL)

4. Restart the service:

Perform:

Killall mysqld (kill MySQL process)

/etc/init.d/mysql start (start MySQL service)

MySQL 1045 Login failed (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.