mysql -h host(指定数据库地址) -u账号 -p密码 -P3306 -e"SELECT CONCAT('\"', a.id, '\"') AS 主账号网站ID, a.cust_right_group AS 权限级别, a.pay_end_date AS 到期时间, c.sname AS 负责人, COUNT(d.id) AS 子账号数量, CONCAT('\"', GROUP_CONCAT(d.id ORDER BY d.id ASC SEPARATOR ', '), '\"') AS 对应子账号ID FROM meminfo.v_member_info a LEFT JOIN crm2.user_member_meta b ON a.id = b.memberId LEFT JOIN crm2.user_meta c ON b.staffId = c.sid LEFT JOIN meminfo.yuan_user d ON a.id = d.company_id WHERE a.cust_right_group > 0 AND a.pay_end_date >= '2023-11-09 00:00:00' GROUP BY a.id, a.cust_right_group, a.pay_end_date, c.sname ORDER BY a.id ASC"> /home/ops/sqlback/memberinfo_all.txt
SELECT CAST( a.id ASCHAR ) AS 主账号网站 ID, a.cust_right_group AS 权限级别, a.pay_end_date AS 到期时间, c.sname AS 负责人, COUNT( d.id ) AS 子账号数量, GROUP_CONCAT( CAST( d.id ASCHAR ) ORDERBY d.id ASC ) AS 对应子账号 ID FROM meminfo.v_member_info a LEFTJOIN crm2.user_member_meta b ON a.id = b.memberId LEFTJOIN crm2.user_meta c ON b.staffId = c.sid LEFTJOIN meminfo.yuan_user d ON a.id = d.company_id WHERE a.cust_right_group >0 AND a.pay_end_date >='2023-11-09 00:00:00' GROUPBY a.id, a.cust_right_group, a.pay_end_date, c.sname ORDERBY a.id ASC LIMIT 20, 20;
SELECT C.ORDINAL_POSITION AS 列 的 排 列 顺 序, T.TABLE_NAME AS 表 名, T.TABLE_COMMENT AS 表 注 释, C.COLUMN_NAME AS 列 名, C.COLUMN_COMMENT AS 列 注 释, C.COLUMN_TYPE AS 数 据 类 型, C.IS_NULLABLE AS 是 否 为 空, C.COLUMN_DEFAULT AS 默 认 值, C.EXTRA AS 代 码 表, C.COLUMN_KEY AS 键, C.COLLATION_NAME AS 约 束 条 件 FROM information_schema.TABLES T LEFTJOIN information_schema.COLUMNS C ON T.TABLE_NAME = C.TABLE_NAME AND T.table_schema = C.table_schema WHERE T.TABLE_NAME ='posts' and T.TABLE_SCHEMA ='rsshub_blog' ORDERBY C.TABLE_NAME, C.ORDINAL_POSITION;
列的排列顺序
表名
表注释
列名
列注释
数据类型
是否为空
默认值
代码表
键
约束条件
1
posts
id
int unsigned
NO
NULL
auto_increment
PRI
NULL
2
posts
title
varchar(255)
YES
NULL
utf8mb4_general_ci
3
posts
desrc
varchar(255)
YES
NULL
utf8mb4_general_ci
4
posts
ver
varchar(255)
YES
NULL
utf8mb4_general_ci
5
posts
cover
varchar(255)
YES
NULL
utf8mb4_general_ci
6
posts
status
tinyint(1)
YES
NULL
NULL
7
posts
images
longtext
YES
NULL
utf8mb4_general_ci
8
posts
ad_read
tinyint(1)
YES
NULL
NULL
9
posts
notice
varchar(255)
YES
NULL
utf8mb4_general_ci
10
posts
created_at
datetime(6)
YES
NULL
NULL
11
posts
updated_at
datetime(6)
YES
NULL
NULL
12
posts
published_at
datetime(6)
YES
NULL
NULL
13
posts
created_by_id
int unsigned
YES
NULL
MUL
NULL
14
posts
updated_by_id
int unsigned
YES
NULL
MUL
NULL
更新一列数据,在某一列前拼上指定字符串
1
UPDATE `rsshub_blog`.`posts` SET cover = CONCAT('https://chengzc.club/?url=', cover);
用户和权限
1 2 3 4 5 6 7 8 9 10 11 12 13 14
--显示当前用户信息和对应的权限 SHOW GRANTS; --显示数据库所用用户和对应地址的权限 SHOW GRANTS; SELECTDISTINCT CONCAT( 'User: ''', USER, '''@''', HOST, ''';' ) AS QUERY FROM mysql.USER; --创建用户 CREATEUSER'用户'@'指定IP' IDENTIFIED BY'密码'; --指定数据库权限 GRANTALL PRIVILEGES ON `eoapi`.*TO'用户'@'指定IP'; --刷新缓存 FLUSH PRIVILEGES