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 UserGrant all privileges on a database to a single user:
</p> <p>mysql> CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'new_password';</p> <p>
<br> mysql> GRANT ALL ON my_db.* TO 'new_user'@'localhost';<br>
Or…
<br> mysql> 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> 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> 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> ERROR 1396 (HY000): Operation DROP USER failed for 'testuser'@'localhost'</p> <p>