Error 1045 occurs due to a denied access to the database
The content of the article:
- 1 Causes of Access denied for user ‘root @ localhost error
- 2 How to fix error 1045 in MySQL
Causes of Access denied for user ‘root @ localhost error
To access MySQL freely, three must match parameters describing the database user – name, car name and password. If there are any discrepancies, access will be denied. The simplest cause of the problem is incorrect password entry. In addition, it can cause an error. incorrect syntax.
There is no simple username dependency in the MySQL system – password, host name plays an important role in gaining access to the database. It can be in the form of an IP address, domain name, keyword (e.g. localhost) or a character that combines multiple machines in group (for example,% – any host except the local one).
The error has a key (Using password: NO) when entering the database through browser
The most common errors when accessing the database:
- When assigning rights to a new user, the address was not specified the machine with which it can connect. In this case, he it will automatically be allowed to use the database from any host except local, and when you try to connect with localhost, an error occurs access.
- Incorrectly placed quotation marks. If when creating user write ‘username @ localhost, this will mean that username @ localhost can connect from any machine except local and not that username can connect from a computer localhost. Username and machine name must have their own pair quotation marks.
- Using a password if it is not in the database.
Depending on which method of connecting to the database Access denied for user ‘root @ localhost (Using password: YES or NO), different solution methods are used Problems.
How to fix error 1045 in MySQL
If the error is Access denied for user ‘root @ localhost (Using password: YES and NO) appears with Using password: YES, The problem is the password is entered incorrectly. Check it out it is possible, having opened the mysql.user table in which data on all users.
The mysql.user table stores user login information
The procedure is as follows:
- Open the user table.
- Check if the root user exists with the localhost host. If there is one, look at the “password” field. If there is empty, go to The database can be entered without a password. If there is something there, then you enter the wrong password.
- Change the password with the SET PASSWORD command.
- If there is no root user, create it, set a password and grant him rights.
After that, you can enter the database. If you do not change the data it turns out that you should use the –skip-grant-tables parameter, which overrides all permission settings.
Lines to be changed in the configuration file
If the error appears with the key (Using password: NO), you need do the following modify the config.inc.php file, specifying in it correct data. If the problem occurs when installing MySQL, need to delete the databases of the old version of the program or change password to access them using the -skip-grant-tables mode.
So the error is Access denied for user ‘root @ localhost (Using password: YES or NO) occurs when the password does not match and username and is easily fixed by replacing data for entrance.