Skip to content

Commit cd993c0

Browse files
committed
grant privileges to user
1 parent 7fc90c1 commit cd993c0

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

docs/.vitepress/config.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export default defineConfig({
2727
],
2828
nav: nav(),
2929
sidebar: {
30+
"/database": sidebarDatabase(),
3031
"/os": sidebarOs(),
3132
"/others": sidebarOthers(),
3233
}
@@ -37,11 +38,23 @@ export default defineConfig({
3738
function nav()
3839
{
3940
return [
41+
{text: "数据库", link: "/database/mysql/grant-privileges-to-user", activeMatch: "/database"},
4042
{text: '操作系统', link: '/os/macos/toggle-toolbar-and-dock-status', activeMatch: '/os'},
4143
{text: '其他', link: '/others/vitepress/getting-started', activeMatch: '/others'},
4244
];
4345
}
4446

47+
function sidebarDatabase()
48+
{
49+
return [
50+
{
51+
text: "MySQL",
52+
items: [
53+
{text: "MySQL 用户授权", link: "/database/mysql/grant-privileges-to-user"},
54+
]
55+
}
56+
];
57+
}
4558

4659
function sidebarOs() {
4760
return [
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# MySQL 用户授权
2+
3+
```sql
4+
-- 创建数据库
5+
CREATE DATABASE `database_name`;
6+
7+
-- 赋权
8+
CREATE USER 'database_username'@'localhost' IDENTIFIED BY 'username_password';
9+
GRANT ALL PRIVILEGES ON `database_name`.* TO `database_username`@'localhost';
10+
11+
-- 查看用户权限情况
12+
SHOW GRANTS FOR 'database_username'@'localhost';
13+
14+
-- 回收权限和用户
15+
REVOKE ALL PRIVILEGES ON `database_name`.'table_name' FROM `database_username`@'localhost';
16+
DROP USER `database_username`@'localhost';
17+
```

0 commit comments

Comments
 (0)