Basic MySql commands

1. How to log in mysql
mysql -u root -p
Then input password.

2. How to log out
mysql> exit

3. How to delete a database or a user
mysql> drop schema <database_name>;
mysql> drop user <a_user_name>; 
mysql> drop user <another_user_name>; 
mysql> FLUSH PRIVILEGES; 

Or,
mysql> drop database <db_name>; 
mysql> FLUSH PRIVILEGES;

4. List existing users in mysql
log in as root first
mysql> select User from mysql.user;

4. List existing databases in mysql
log in as root first
mysql> show databases;

Advertisements