1. 链接数据库:mysql -uroot -proot0001
2. 查看数据库: show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.05 sec)
3. 创建数据库: create database corderhub;
4. 查看当前选中数据库:select database();
4. 切换数据库: use corderhub;
5. 创建表到指定的数据库: create table users();
6. 插入数据到数据库: insert into users (name, age, height) values ('why', 18, 1.88);
7. 查看表: select * from users;
+------+------+--------+
| name | age | height |
+------+------+--------+
| why | 18 | 1.88 |
| wh | 17 | 1.68 |
| zs | 18 | 1.73 |
+------+------+--------+
3 rows in set (0.00 sec)