User Tools

Site Tools

  • [tamara] Migrate MySQL

A brief cheatshet for the LARICS sysadmin, to ease the pains of SQL DB administration for our various web-based services.

Commands from the mySQL console

Enter the mySQL console:

$ mysql -u username -p

List all databases on the server:

mysql> show databases;

Select a database:

mysql> use databasename;

Show all tables in the database:

mysql> show tables;

See a table's field formats:

mysql> describe tablename;

Create a database:

mysql> create database databasename;

Commands from the system console

To back up a database (e.g. to migrate to another SQL server):

$ mysqldump -u root -p --opt db_name > backupname.sql

The –opt option creates an optimized dump, which will result in faster read times when loaint to another MySQL server.

To restore the database:

$ mysql -u root -p db_name < backupname.sql

For the above statement to work, you must create the database db_name (see the above section for instructions).


  • mySQL Intro - if it is your first contact with a mySQL database, read this first
  • Commands - a comprehensive list of MySQL commands
software/mysql.txt · Last modified: 2017/05/12 09:29 (external edit)