I am trying to execute this queries -
DROP DATABASE IF EXISTS `hotel`; GRANT USAGE ON *.* TO 'user'@'localhost'; DROP USER 'user'@'localhost'; CREATE USER user@localhost IDENTIFIED BY 'user'; CREATE DATABASE `hotel` CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'; GRANT USAGE ON *.* to 'user'@'localhost' identified by 'user';
But I always get error on
GRANT USAGE ON *.* TO 'user'@'localhost' Error Code: 1133. Can't find any matching row in the user table 0.000 sec
I thought that Grant usage
create new user if user does not exist. What is wrong?
To GRANT ALL privileges to a user , allowing that user full control over a specific database , use the following syntax: mysql> GRANT ALL PRIVILEGES ON database_name. * TO 'username'@'localhost';
Use the following query to show MySQL users created in the database server: SELECT user FROM mysql. user; As a result, you will see the list of all the users that have been created in MySQL.
If the --skip-grant-tables option was specified at server startup to disable the MySQL privilege system, FLUSH PRIVILEGES provides a way to enable the privilege system at runtime. Frees memory cached by the server as a result of GRANT , CREATE USER , CREATE SERVER , and INSTALL PLUGIN statements.
The mysql. user table contains information about users that have permission to access the MariaDB server, and their global privileges. The table can be queried and although it is possible to directly update it, it is best to use GRANT and CREATE USER for adding users and privileges.
I got the same error with
grant all on newdb.* to newuser@localhost;
solved with 'identified by':
grant all on newdb.* to newuser@localhost identified by 'password';
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