I recently started to learn MySQL, mainly through books and videos from instructor Yan 18, and then recorded my learning process through blogs.
Log on to the database
zhiniaobu@telunsu-K55VD:~$ mysql -uroot -pEnter password:
View all current databases
Mysql> show databases; # view all current databases + -------------------- + | Database | + -------------------- + | information_schema | ceshi | mysql | performance_schema | + -------------------- + 4 rows in set (0.04 sec)
Create Database ceshi1
Mysql> create database ceshi1; # create a database ceshi1Query OK, 1 row affected (0.00 sec) mysql> show databases; # view all current databases, A ceshi1 + -------------------- + | Database | + -------------------- + | information_schema | ceshi | ceshi1 | mysql | performance_schema | + rows + 5 rows in set (0.00 sec)
View database ceshi1 Definitions
Mysql> show create database ceshi1; # view the definition of the Database ceshi1 + ---------- + certificate + | Database | Create DATABASE | + ---------- + certificate + | ceshi1 | CREATE database 'ceshi1 '/*! 40100 default character set latin1 */| + ---------- + ----------------------------------------------------------------- + 1 row in set (0.00 sec)
Delete database ceshi1
Mysql> drop database ceshi1; # Delete the database ceshi1Query OK, 0 rows affected (0.07 sec) mysql> show databases; # view all current databases, and now you will find that ceshi1 does not exist, because it has been deleted + ------------------ + | Database | + -------------------- + | information_schema | ceshi | mysql | performance_schema | + ------------------ + 4 rows in set (0.00 sec)