Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't find any matching row in the user table

Tags:

mysql

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?

like image 686
lapots Avatar asked Jul 11 '13 15:07

lapots


People also ask

How do I grant all privileges to a database in MySQL?

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

How do I show users in MySQL?

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.

What does flush privileges do 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.

What is MySQL user table?

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.


1 Answers

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'; 
like image 186
Ricardo Rivaldo Avatar answered Oct 09 '22 00:10

Ricardo Rivaldo