How to Create a MySQL User: Remove a MySQL User, Show a MySQL User

This article shows how to create a MySQL user, remove a MySQL user and to show a list of MySQL users.

Read more: How to Create a MySQL User: Remove a MySQL User, Show a MySQL User

Grant all privileges on a database to a single user:

</p>
<p>mysql&gt; CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'new_password';</p>
<p>

<br>
mysql&gt; GRANT ALL ON my_db.* TO 'new_user'@'localhost';<br>

Or…

<br>
mysql&gt; GRANT ALL PRIVILEGES ON database_name.* to 'new_user'@'localhost' IDENTIFIED BY 'password';<br>

Remove a USer from Mysql

Review a List of MySQL Users

</p>
<p>mysql&gt; SELECT User,Host FROM mysql.user;</p>
<p>

Remove a MySQL User
To remove a user from MySQL, we again use the DROP command.

It only takes one simple command to delete a user in MySQL, but BEWARE; dropping a user can not be undone! The command is as follows:

</p>
<p>mysql&gt; DROP USER 'testuser'@'localhost';</p>
<p>

If a user of the name testuser does not exist, then you’ll receive this error:

</p>
<p>mysql&gt; ERROR 1396 (HY000): Operation DROP USER failed for 'testuser'@'localhost'</p>
<p>

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.