Mysql – Delete MySQL database and users

databaseMySQL

I want to delete my database and the user for it because I need to make a new import. Normally I do this through cPanel but it doesnt seem to delete it, even though it states that it did.

So guys, how the heck do I do this? Maybe there is a way to do it in WHM? Im running RedHat x86_64 es5. I am not experienced with servers so please be specific in any replies. Cheers!

Best Answer

First ssh into your box. Like this:

ssh username@ip

Assuming you have not disabled password authentication, you should be able to enter your username / password after this.

Then, get into mysql:

sudo mysql -p

Enter your root mysql password. Now you can run:

show databases;

To see databases you have

drop database databasename;

To delete a database

select * from mysql.user;

To see all of the current mysql users

delete from mysql.user where id = x;

Where x is the id of the user you want to delete, deletes user.

Hope that helps! As alvosu said, reading the documentation is the best place to start.