I try to add a user to my database using phpMyAdmin.
When I add the user the following way everything works fine:
UserName: user Password: pass Host: localhost
But when I create the same user and use "%" instead of localhost he cannot log in (even from localhost)
What can be the issue here?
(Update): This is the command that is generated:
CREATE USER 'user'@'%' IDENTIFIED BY '***';GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' IDENTIFIED BY '***' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0
(password has been removed by phpmyadmin)
Here are some reasons the Can't connect to local MariaDB server error might occur: mysqld is not running on the local host. Check your operating system's process list to ensure the mysqld process is present. You're running a MariaDB server on Windows with many TCP/IP connections to it.
In fact MariaDB is fully compatible with MySQL since it was (and still is) intended to be a perfect replacement for MySQL. A standard MySQL installation comes bundled with a couple of useful tools, such as mysqldump, which is helpful for backups. It can be used with both MySQL and MariaDB.
'%' mean you can login into database from any host connected to those database. You also define your localhost as host if you want to access database from localhost. to change your password: SET PASSWORD FOR 'me'@'%' = PASSWORD('letmein');
The default host is localhost . By default, MariaDB does not permit remote logins - see Configuring MariaDB for Remote Client Access.
Make sure you don't have any Anonymous Users.
From the Mysql Documentation
If you cannot figure out why you get Access denied, remove from the user
table all entries that have Host
values containing wildcards (entries that contain %
or _
characters). A very common error is to insert a new entry with Host='%'
and User='some_user'
, thinking that this enables you to specify localhost to connect from the same machine. The reason that this does not work is that the default privileges include an entry with Host='localhost'
and User=''
. Because that entry has a Host value localhost
that is more specific than %
, it is used in preference to the new entry when connecting from localhost! The correct procedure is to insert a second entry with Host='localhost'
and User='some_user'
, or to delete the entry with Host='localhost'
and User=''
. After deleting the entry, remember to issue a FLUSH PRIVILEGES
statement to reload the grant tables.
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