This question seem to be asked a lot however I cannot find a definitive answer.
I am making some webapp tests using MySQL, and at the beginning I used the 'root' user (with a non-empty password). My root user is working fine from the apps (tested from PHP and Python's Django), from the command line, and with PHPMyAdmin.
However I don't wanted to use the the root user, so I created another user, and I granted all privileges to the databases that user should need. (I used PHPMyAdmin logged as 'root' for this task).
The new user cannot log in to MySQL. Neither from the Django app, nor PHPMyAdmin, nor the command line.
I have two possible suspicions:
there is a global privilege the user lacks. (As I said, I granted all database privileges, however I have not granted any global privileges);
the user's configured host. ('root' has four lines in the mysql.user table, for hosts 'localhost', 'my-pc-name', '127.0.0.1' and '::1'; while the new user has one line for host '%')
(I have double-checked the password, so I am confident this is not a password problem.)
To resolve the error, you must create a user with the following command: mysql> GRANT ALL ON *. * to user_name@localhost IDENTIFIED BY 'password'; Replace user_name with the user's username and password with the user's password.
This is a solution, Error 1045 MySql Instalation. go to firewall from control panel, click on advanced setting in the left panel. Now, click on inbound rules. Add two mysql's under name one with Domain Profile the other with Private Profile.
Use the ALTER USER command and change the authentication method to log into MySQL as root: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'insert_password'; This command changes the password for the user root and sets the authentication method to mysql_native_password.
How to fix “Error 1045 (28000) access denied for user 'root'@'localhost' (using password: yes)”? It arises when you perform a fresh installation of MySQL and try to login with a password. The default password of MySQL is blank () (i.e. empty string). So, you can login to the MySQL server using the same password.
% means that the new user can access the database from any host.
However, if you supplied the CREATE USER statement would be much more useful.
In addition, check MySQL Manual below, where it explains why a user should have both @'localhost'
and @'%'
:
MySQL Reference Manual - Adding Users
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With