Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql CREATE USER

Tags:

database

mysql

I am logged into mysql...

mysql -u root -pmypass

And I have run the following command to remove the database user which worked succesfully

mysql> FLUSH PRIVILEGES; DROP USER 'myuser_shop';

I can then add user successfully using the following command, again this works successfully

mysql> FLUSH PRIVILEGES; CREATE USER 'myuser_shop' IDENTIFIED BY 'mypass';

The above command create a user with the host as a wildcard (%) The issue I am having is if I was to create a user with the host being say localhost or an external IP i get the following error:

mysql> FLUSH PRIVILEGES; DROP USER 'myuser_shop';
mysql> FLUSH PRIVILEGES; CREATE USER 'myuser_shop'@'localhost' IDENTIFIED BY 'mypass';

Query OK, 0 rows affected (0.00 sec)

ERROR 1396 (HY000): Operation CREATE USER failed for 'myuser_shop'@'localhost'

Any suggestions?

Thanks in advance

like image 760
Lizard Avatar asked Nov 03 '09 14:11

Lizard


People also ask

How do I create a user in MySQL?

Create a new MySQL user account mysql> CREATE USER 'local_user'@'localhost' IDENTIFIED BY 'password'; This command will allow the user with username local_user to access the MySQL instance from the local machine (localhost) and prevent the user from accessing it directly from any other machine.

How do you create a database user?

Expand the database in which to create the new database user. Right-click the Security folder, point to New, and select User.... In the Database User - New dialog box, on the General page, select one of the following user types from the User type list: SQL user with login.

Why do we create user in MySQL?

The MySQL user is a record in the USER table of the MySQL server that contains the login information, account privileges, and the host information for MySQL account. It is essential to create a user in MySQL for accessing and managing the databases.


2 Answers

This is a bug reported here - http://bugs.mysql.com/bug.php?id=28331

See if your user exists after you drop it.

like image 122
Svetlozar Angelov Avatar answered Oct 17 '22 03:10

Svetlozar Angelov


Check following 2 tables if user is still there after DROP USER command: mysql.user and mysql.db.

Delete user from both, then run FLUSH PRIVILEGES and then you can recreate the user.

like image 21
Alexei Tenitski Avatar answered Oct 17 '22 03:10

Alexei Tenitski