Mysql Notes / mysql queries on command line

  • Sunny
  • 3577 Views
  • 0 Comment
  • No tags

Supportlobby share some tips which we are using while dealing with mysql databases.

‘-e’ is the switch which enables command line mode for ‘mysql’ client which is installed default on every Linux distros.

Some examples:

1. For listing all mysql users on the server.

mysql mysql -e "SELECT User FROM user"

2. Show values assisned to each mysql variable

mysql -e "SHOW VARIABLES"

3. For list mysql engine details

mysql -e "SHOW ENGINES"

4. Dropping a database

mysql -e "DROP DATABASE dbname"

5. Dropping a user

mysql -e "DROP USER user"

Some rules regarding “DROP USER”. Click on me for more details

6. Show privilages of currently logged in mysql user

mysql -e "SHOW GRANTS"

7. Listing complete databases on the server

mysql -e "SHOW DATABASES"

8. Listing databases and its user

mysql mysql -e "select Db,User from db"
 
0 Comments
Leave a comment
OUR SERVICES
OUR TECHNOLOGIES