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.)
% 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 @'%'
: