Thursday, 12 October 2017

Mysql Command line cheat sheet

List of mysql commands


Connecting Mysql : mysql -u username -p  ( will prompt for password )

Show all databases : show databases;

Create a new database : create database database_name;

Select database: use database_name;

Show all tables : show tables;

Show table structure : describe table_name;

MySQL open database connections : show status like '%onn%';

 MySQL show processlist : show processlist;

Deleting tables : drop table table_name;

Deleting databases: drop database database_name;

Export a database dump : mysqldump -u username -p database_name > database_dump.sql

Import a database dump : mysql -u username -p database_name < database_dump.sql

Create a new user: create user 'username'@'localhost' identified by 'password'

List out the users : select user,password,host from mysql.user

No comments:

Post a Comment