usunyu   Stay hungry. Stay foolish.

MySQL Command Tips

Invoke MySQL:

$ mysql
$ mysql -u root -p
$ mysql --user=your-user-name --password=your-password

Create the Database:

mysql> CREATE DATABASE my_db;
mysql> SHOW databases;
mysql> USE my_db;

Create a Table:

mysql> CREATE TABLE user (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, username CHAR(25), passward CHAR(100));

Create an entry in the table:

mysql> INSERT INTO user (id, username, passward) VALUES (NULL, 'name', 'secrect');

Create more entries:

mysql> INSERT INTO user (id, username, passward) VALUES (NULL, 'name2', 'secrect2'), (NULL, 'name3', 'secrect3'), (NULL, 'name4', 'secrect4');

Export, Import MySQL Database

$ mysqldump -u user -p db-name > db-name.out
$ mysql -u user -p db-name < db-name.out

Resource: