Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wildcard Host not working in MariaDB (MySQL)

Tags:

mysql

mariadb

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)

like image 734
Ole Albers Avatar asked Jan 19 '15 22:01

Ole Albers


People also ask

Can't connect to MySQL server on MariaDB?

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.

Is MariaDB compatible with MySQL?

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.

What does @% mean for host in MySQL?

'%' 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');

What is host in MariaDB?

The default host is localhost . By default, MariaDB does not permit remote logins - see Configuring MariaDB for Remote Client Access.


1 Answers

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.

like image 78
DavidScherer Avatar answered Oct 08 '22 07:10

DavidScherer