题1
导入数库据,并查询
[root@use01 ~]# mysql -uroot -p123 < hellodb_innodb.sql
[root@use01 ~]# mysql -uroot -p123
MariaDB [(none)]> use hellodb;
MariaDB [hellodb]> select name,age from students where age > 25 and gender = 'm';
+--------------+-----+
| name | age |
+--------------+-----+
| Xie Yanke | 53 |
| Ding Dian | 32 |
| Yu Yutong | 26 |
| Shi Qing | 46 |
| Tian Boguang | 33 |
| Xu Xian | 27 |
| Sun Dasheng | 100 |
+--------------+-----+
7 rows in set (0.00 sec)
MariaDB [hellodb]> select classid,avg(age) from students group by classid;
+---------+----------+
| classid | avg(age) |
+---------+----------+
| NULL | 63.5000 |
| 1 | 20.5000 |
| 2 | 36.0000 |
| 3 | 20.2500 |
| 4 | 24.7500 |
| 5 | 46.0000 |
| 6 | 20.7500 |
| 7 | 19.6667 |
+---------+----------+
8 rows in set (0.00 sec)
MariaDB [hellodb]> select classid,avg(age) from students group by classid having avg(age) > 30;
+---------+----------+
| classid | avg(age) |
+---------+----------+
| NULL | 63.5000 |
| 2 | 36.0000 |
| 5 | 46.0000 |
+---------+----------+
3 rows in set (0.00 sec)
MariaDB [hellodb]> select * from students where name like 'l%';
+-------+-------------+-----+--------+---------+-----------+
| StuID | Name | Age | Gender | ClassID | TeacherID |
+-------+-------------+-----+--------+---------+-----------+
| 8 | Lin Daiyu | 17 | F | 7 | NULL |
| 14 | Lu Wushuang | 17 | F | 3 | NULL |
| 17 | Lin Chong | 25 | M | 4 | NULL |
+-------+-------------+-----+--------+---------+-----------+
3 rows in set (0.00 sec)
题2
用户授权
MariaDB [hellodb]> grant all on hellodb.* to mage@'192.168.1.0/24' identified by '123';
题3
mysql常见存储引擎,myisam,innodb
下面简要的写一下它们之间的区别:
myisam | innodb | |
---|---|---|
最大内存占用 | 256TB | 64TB |
锁类型 | 表 | 行 |
MVCC | NO | YES |
外键 | NO | YES |
聚集索引 | NO | YES |
压缩 | YES | YES |
表文件 | .frm .MYD .MYI | .frm .ibd |
缓存内容 | 索引 | 数据、索引 |