Mysql基本操作

一、Mysql启动和关闭的命令

1. windows下面的命令:

1.1 在命令行连接 :

mysql -u root -p (本地连接)

1.2 启动/关闭命令:

.启动mysql:输入 net start mysql;

.停止mysql:输入 net stop mysql;

1.3 Qcache_hits表示sql查询在缓存中命中的累计次数,是累加值。

mysql> SHOW STATUS LIKE 'Qcache_hits';

1.4 查看mysql文件册存储信息位置:

SHOW VARIABLES LIKE '%data%'

1.5 导出建表语句:

SHOW CREATE TABLE 表名称;

1.6 退出:

quit;

二、查询缓存(开启、关闭)

1. 怎么查看是不是开启了缓存的命令:

网上总是说缓存是默认开启的,但是我看家的都是默认没有开启的,需要手动开启;

mysql> SHOW VARIABLES LIKE '%query_cache%';
+------------------------------+---------+
| Variable_name                | Value   |
+------------------------------+---------+
| have_query_cache             | YES     | --查询缓存是否可用
| query_cache_limit            | 1048576 | --可缓存具体查询结果的最大值
| query_cache_min_res_unit     | 4096    | 
| query_cache_size             | 599040  | --查询缓存的大小
| query_cache_type             | OFF     | --阻止或是支持查询缓存
| query_cache_wlock_invalidate | OFF     | 
+------------------------------+---------+

2. 现在我们看一下在不同的操作系统下面开启缓存的方式:

2.1 windows 系统

修改 my.ini [mysqld]中添加:

query_cache_size = 20M

query_cache_type = ON

2.2 linux 系统

> vi /etc/my.cnf

[mysqld]中添加:

query_cache_size = 20M

query_cache_type = ON

 三、看存储引擎

1. 看mysql支持的存储引擎

SHOW ENGINES;

2. 看mysql默认的存储引擎

SHOW VARIABLES LIKE '%storage_engine%';

 

原文地址:https://www.cnblogs.com/lys-lyy/p/11156762.html