1. Installation
  2. Examples
    1. Add a user
  3. Moving a database
    1. Export the Data
    2. Import the Data

Installation

> apt-get install mysql-server
> mysqladmin -u root password 'new-password'

Examples

Add a user

Add a user and give them access to a database:

> mysql --user root -p 
mysql> use mydatabase;
mysql> grant all on mydatabase.* to myuser@localhost identified by 'your_password';
mysql> flush privileges;
mysql> quit

Moving a database

Export the Data

There are lots of ways of creating a data file for export. Here are some useful examples:

standard dump, including create database commands:
> mysqldump --user=root --password={rootpw} --quick --databases {dbname} > data.sql

some other options. without the --databases there will be no "CREATE DATABASE":
> mysqldump --host={hostname} --port=3306 --complete-insert --lock-tables {database} > data.sql 

Import the Data

> mysql -u root -p < data.sql

you may have to "DROP DATABASE mydb" first, and then "CREATE DATABASE mydb".