mysql 权限管理 记录

论坛 期权论坛 脚本     
匿名技术用户   2020-12-30 09:19   11   0

授权操作只能用root账号,其他账号都不行

创建一个mike账号

mysql> create user 'mike'@'localhost' identified by '123';
Query OK, 0 rows affected (0.08 sec)

查看是否创建账号

select * from mysql.user\G;

默认创建账号 在user表里没有放行授权 红色框是权限

但这个账号在其他表会有权限 例如 db表

select * from mysql.db\G;

user 是空的 包括任意用户,包括创建的mike账号 ,在db表里都有权限

HOST % 代表包括任意ip ,包括远程和本地

mike这个用户 对test这个库有权限,还对test_开头的库有权限

创建两个库测试下

mysql> create database test_1 charset=utf8;
Query OK, 1 row affected (0.13 sec)

mysql> create database test2 charset=utf8;
Query OK, 1 row affected (0.00 sec)

退出重新登录

mysql> exit
Bye
[root@mysql ~]# mysql -umike -p123
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 2
Server version: 5.6.36 Source distribution

Copyright (c) 2000, 2017, 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> 

没有test2库,可以看到test、test_1数据库,可以对test、test_1数据库,里面的表进行增删改查

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test               |
| test_1             |
+--------------------+
3 rows in set (0.05 sec

db表默认对test库放行权限,默认如果想针对某个库,就要对db这张表授权了

转载于:https://www.cnblogs.com/mingerlcm/p/9925394.html

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP