What is the difference between '<username>'@localhost vs '<username>'@'%'?
Hello,
What is the difference between the next two lines:
CREATE USER '<username>'@localhost IDENTIFIED BY '<password>'; -- Stap 2. User creation CREATE USER '<username>'@'%' IDENTIFIED BY '<password>';
Defined with '%', user has rights to every instance of database schema and just with localhost...? Something like that?
Answer Answered by Markus Mäkelä in this comment.
The @localhost
user can only connect to MariaDB from the same machine where the server is located. The @%
user is allowed to connect from anywhere. If you were to use something like 'username'@'192.168.0.123'
then the user would be only allowed to connect from that IP address.
What the user is allowed to do on the database is controlled with the GRANT SQL command. By default newly created userd are allowed to do very little and access to the tables needs to be granted.
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.