Skip to content

Commit 2ad0fc5

Browse files
authored
Update 常用操作.md
1 parent b8c8909 commit 2ad0fc5

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

database/MySQL/常用操作.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,19 @@ mysqlimport -u root -p --local database_name dump.txt
7676
```
7777
ALTER TABLE test002.test_data002 ADD INDEX index_type (type) , ALGORITHM=INPLACE, LOCK=NONE;
7878
```
79+
80+
### 导出数据到文件
81+
```
82+
mysql -h${host} -u${user} --password=${password} --database=${db_name} --execute="select ${col1} AS '${col1_name}',case when(${col2}=1) then '${col2_name1}' else '${col2_name2}' end as '${col2_alias_name}' from ${table}" -X > /${dir}/${file}.xlsx
83+
```
84+
85+
### 创建用户
86+
```
87+
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
88+
```
89+
90+
### 授予权限
91+
```
92+
GRANT SELECT ON *.* TO 'readonly'@'%' IDENTIFIED BY '${password}';
93+
GRANT SELECT ON *.* TO 'readonly'@'%';
94+
```

0 commit comments

Comments
 (0)