mysql5.6.24 版本上创建实例并授权操作

以下操作命令和方法均是在 mysql5.6.24 版本上,其他版本略有差异。

一、登录mysql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@db-1-198 ~]# mysql -h127.0.0.1 -uroot -p'DbMingX28' -P3306 -S /tmp/mysql3306.sock
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 26611867
Server version: 5.6.24-log MySQL Community Server (GPL)
 
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

二、查看现有的数据库实例

1
2
3
4
5
6
7
8
9
10
mysql> show databases;
+------------------------+
| Database         |
+------------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+------------------------+
4 rows in set (0.01 sec)

三、创建数据库实例

1
2
3
4
5
6
7
8
9
10
mysql> show databases;
+------------------------+
| Database |
+------------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+------------------------+
4 rows in set (0.01 sec)

四、创建用户并授权该实例的所有权限给新创建的用户

1
2
3
4
5
6
7
8
9
10
11
12
13
14
mysql> grant all on wangming.* to 'wmuser'@'192.168.1.%' identified by 'Pz4p6uA13K';
Query OK, 0 rows affected (0.00 sec)
 
mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)
 
mysql> show grants for 'wmuser'@'192.168.1.%';
+-----------------------------------------------------------------------------------------------------------------------+
| Grants for wmuser@192.168.1.% |
+-----------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'wmuser'@'192.168.1.%' IDENTIFIED BY PASSWORD '*4C1597C9C4060CCA85B46F5851DFEEEAF2BE459F' |
| GRANT ALL PRIVILEGES ON `wmuser`.* TO 'wmuser'@'192.168.1.%' |
+-----------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

五、使用新创建的用户测试登录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[root@db-1-198 ~]# mysql -h192.168.1.198 -uwmuser -p'Pz4p6uA13K' -P3306 -S /tmp/mysql3306.sock
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 26612703
Server version: 5.6.24-log MySQL Community Server (GPL)
 
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| pre_assessrv_wl |
| test |
+--------------------+
3 rows in set (0.00 sec)
 
mysql>

完工

posted @   MR__Wang  阅读(113)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端
历史上的今天:
2018-08-17 使用htpasswd实现Nginx验证访问
点击右上角即可分享
微信分享提示