BLOG

BLOG

MySQL command-line cheat sheet

Jun 7, 2013

Just a few copy/paste ready commands for some basic MySQL tasks.

Log in to MySQL command line as root user

mysql -u root -p

Add a new database

create database namegoeshere;

Give a user access to a database

grant all privileges on namegoeshere.* to user@localhost identified by 'password';

Drop a database

drop database namegoeshere;

Export/dump database to sql text file

mysqldump -u username -p namegoeshere > filename.sql

To import database from dump file

mysql -u username -p  namegoeshere < filename.sql

0 Comments