MYSQL 1045 Error

Source: Internet
Author: User

  Run the MySQL Instance configuration Wizard as an administrator when configured

When you log in to the MySQL database: Error 1045 errors (such as), it indicates that you entered the user name or password error is denied access, the simplest solution is to unload the MySQL database and then reinstall, but the disadvantage is that the information in the previous database will be lost, if you do not want to reinstall, Then you need to retrieve your password or reset it. 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

    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: Remove or add a # comment to 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 the 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 files record the general parameters of MySQL, This file is loaded each time the service is started, and Skip_grant_tablesis added to the last line of the My.ini configuration file, which ignores login checks.

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 ';        (Remember to add;) (Change password)

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

4. Restart the service:

Delete or add a # comment to the SKIP permission statement 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 Error

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.