Basic MySQL commands

Basic MySQL commands is kind of Cheats Sheet page for starters or an reminder for experienced users.

MS Windows basic MySQL commands

– shutting down server

mysqladmin -u root -p shutdown

– removing service

mysqld –remove

– installing service

mysqld-max –install

– starting up for first time

mysqld-max –standalone


All systems basic  MySQL commands

– first login

mysql -u root

– startup

mysqld –standalone

– setting up root password

set password for root@localhost=password(‘newpassord‘);
type your password instead of newpassword

– login as root

mysql -u root -p

– deleting anonymous accounts

use mysql;
delete from user where User=”;
delete from db where User=”;
flush privileges;

– create new user

grant create, create temporary tables, delete, execute, index, insert, lock tables, select, show databases, update on *.* to username identified by ‘password‘;
type your username instead of username and password instead of password


More basic MySQL commands

– showing databases

show databases;

– using database

use dbname;
type db name instead of dbname

– show tables in database

show tables;

– show table structure

describe tablename;
type your table name instead of tablename

– import commands from file

source filename
type the wanted file name instead filename with extension (full name)

– import commands from file (external)

mysql -u username -p < filename
type username instead of username and file name instead of filename with extension (full name)

– exit

/q or quit

– help



Data bases and tables manipulation

– create database

create database dbname;
type data base name instead of dbname

– delete database

drop database dbname;
type data base name instead of dbname


to be continued…

All product names, logos, and brands are property of their respective owners. All company, product and service names used in this website are for identification purposes only. Use of these names, logos, and brands does not imply endorsement.

MySQL wiki
MySQL home page