How to delete MySQL database and user via command line in Linux?
- AuthorPosts
- November 26, 2019 at 12:02 AM #2140
Santhosh Kumar D
Keymaster@santhoshLogin MySQL.
sudo mysql -u root -p
Deleting a MySQL database.
Identify the MySQL database.
You can list all available databases by using the following command.
mysql> SHOW DATABASES;
The output should be something like this.
+--------------------+ | Database | +--------------------+ | information_schema | | database_name | | mysql | | performance_schema | | test | +--------------------+ 5 rows in set (0.00 sec)
Note the name of the database that you want to delete from the displayed list.
Delete the database.
You can now, delete that particular database by using the following command.
mysql> DROP DATABASE database_name;
Make sure you replace thedatabase_name
with the name of the database that you want to delete.The output should be something like this:
Query OK, 0 rows affected (0.00 sec)
Deleting a MySQL user.
Identify the MySQL user.
Type the following command to list all MySQL users.
mysql> SELECT User FROM mysql.user;
The output should be something like this:
+-------+ | User | +-------+ | root | +-------+ | newuser | +-------+
Delete the MySQL user.
You can delete a MySQL user with the following command.
mysql> DROP USER 'newuser'@'localhost';
Make sure to replacenewuser
with the name of the user that you want to delete.The output should be something like this:
Query OK, 0 rows affected (0.01 sec)
- AuthorPosts
Advertisement
RECENT TIPS
- How to send email as an alias in Gmail?
- How to stop Google from tracking your location?
- Command to check the Ubuntu version
- How to add a percentage in Excel?
- How to convert currencies in Google Sheets?
- How to voice type on Google Docs?
- What is Django framework?
- How to turn Google Assistant off?
- How to check the Python version?
- How to create a virtual environment in Python?
- How to change the directory in the Command Prompt?
- How to add a shortcode in WordPress PHP template file?
- Useful websites to research stocks
- How to check Linux uptime?
- How to check Linux last reboot time?