Open Terminal and type this to Log into MySql as root:
$ sudo mysql -u root
Type it to Create new Database
mysql> CREATE DATABASE BIL_359;
Firstly select a Database
mysql> USE BIL_359;
We want to create table with 3 columns as id, name, age.
id is Primary Key and int, name is Varchar, age is int.
mysql> CREATE TABLE bil_359_omeraltuntas(id INT NOT NULL AUTO_INCREMENT, name VARCHAR(50) NOT NULL, age INT NOT NULL, PRIMARY KEY(id));
Verify that the table is created using the DESCRIBE command:
mysql> DESCRIBE bil_359_omeraltuntas;
Insert row to table:
mysql> INSERT INTO bil_359_omeraltuntas(name, age) VALUES("omer altuntas", 20);
Verify that the row is inserted using the SELECT command:
mysql> SELECT * FROM bil_359_omer_altuntas;
Now Insert many row:
mysql> INSERT INTO bil_359_omer_altuntas(name, age) VALUES ("muhammed basoglu", 20), ("ayse yilmaz", 29), ("sezen aksu", 50);
Type it again:
mysql> SELECT * FROM bil_359_omer_altuntas;
Logout from MySql
mysql> exit;
Type it to backup single table
$ sudo mysqldump BIL_359 bil_359_omer_altuntas > bil_359_omer_altuntas.sql
Now Create different Database:
$ sudo mysql -u root
mysql> CREATE DATABASE BIL_359_BACKUP;
And logout:
mysql> exit;
Type this to restore table:
$ sudo mysql -u root BIL_359_BACKUP < bil_359_omer_altuntas.sql
Check.
$ sudo mysql -u root
mysql> USE BIL_359_BACKUP;
mysql> SELECT * FROM bil_359_omer_altuntas;