centos登录mysql
bash
mysql -u <用户名> -p (回车 输入密码)
查看数据库
bash
show databases;
选择数据库
bash
use <数据库名称>
查看表
bash
show tables;
查看数据库端口
bash
show global variables like 'port';
查看数据库版本号
bash
select version();
分组查询(select 字段要包含 group by 字段)
bash
SELECT col_sg_code from sample_info
where col_out ='3''
GROUP BY col_sg_code
ORDER BY col_sg_code desc
分组查询-重复数据
bash
SELECT t.col_code,COUNT(t.col_code) FROM sample_test t
GROUP BY t.col_code
HAVING COUNT(t.col_code) > 1
mysql 加密函数
bash
HEX() 二进制转十六进制
UNHEX() 十六进制转 二进制
AES_ENCRYPT(字符串,秘钥) 加密函数
AES_DECRYPT(字符串,秘钥) 解密函数
查看表空间大小
bash
SELECT CONCAT(ROUND(SUM(data_length)/(1024*1024*1024), 6), ' GB') AS 'Total Data Size'
FROM information_schema.TABLES WHERE table_schema LIKE '数据库名称';