Let's make the world a better place using digital technologies!

Some Useful MySQL Commands

  • mysql -uusername -ppassword
    gets you into MySQL shell
  • show databases;
    shows all the databases;
  • create database databasename;
    creates a new database
  • grant all privileges on databasename.* to 'user'@'localhost' identified by 'password';
    creates user with password with all privileges on given database
  • use databasename;
    selects a database for further actions
  • show tables;
    displays the tables in the selected database
  • drop database databasename;
    deletes all tables in databasename and deletes the database.
  • select * from mysql.user;
    lists all the mysql users
  • drop user xxxx@localhost;
    deletes the xxxx user from the localhost
  • mysqldump --all-databases -p | bzip2 -c > databasebackup.sql.bz2
    dumps all mysql data in the compressed databasebackup.sql.bz2 file.
  • mysqldump -uroot -p databasename | bzip2 -c > databasename.sql.bz2
    dumps databasename database in the compressed databasename.sql.bz2 file.

Asif

http://things.m31.ch

View more posts from this author

Leave a Reply

Your email address will not be published. Required fields are marked *