MySQL管理与权限管理 概述

1.MySQL数据库管理的基本任务

基本任务:

A.运行时间:任何程序或者mysql数据库,都希望数据库的运行时间越长越好,越稳定越好。(内存泄露等问题)

B.数据备份:(msyql数据备份工具)

C.安全和访问控制:

D.性能优化:数据库的IO开销,连接开销

E.使用日志排错和统计

 

2.MySQL授权表

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| dearedu |
| dearedu_my |
| information_schema |
| jikedb |
| my_study |
| mysql |
| performance_schema |
| sys |
+--------------------+
8 rows in set (0.01 sec)

mysql数据库:授权表在此数据库

mysql> show tables from mysql;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| component |
| db |
| default_roles |
| engine_cost |
| func |
| general_log |
| global_grants |
| gtid_executed |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| password_history |
| plugin |
| procs_priv |
| proxies_priv |
| role_edges |
| server_cost |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
33 rows in set (0.01 sec)

查看数据库有哪些用户?

use mysql;

select * from user;

 

Host:主机

User:用户

Select_priv: 查看的权限
Insert_priv: 插入的权限
Update_priv: 更新的权限
Delete_priv: 删除的权限
Create_priv: 创建的权限
Drop_priv: 删除表的权限
Reload_priv: reload的权限
Shutdown_priv: 下载整个数据库的权限
Process_priv: Y
File_priv: Y
Grant_priv: 授权的权限:给其他用户添加权限的权限
References_priv: 属性选项
Index_priv: index索引的权限
Alter_priv: alter修改的权限
Show_db_priv: 查看的权限
Super_priv: 
Create_tmp_table_priv: Y 查看临时表
Lock_tables_priv: Y 锁表的权限
Execute_priv: Y 执行的权限
Repl_slave_priv: Y 
Repl_client_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Create_user_priv: Y
Event_priv: Y
Trigger_priv: Y
Create_tablespace_priv: Y
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
plugin: mysql_native_password
authentication_string: *84AAC12F54AB666ECFC2A83C676908C8BBC381B1
password_expired: N
password_last_changed: 2019-03-15 20:50:17
password_lifetime: NULL
account_locked: N
Create_role_priv: Y
Drop_role_priv: Y
Password_reuse_history: NULL
Password_reuse_time: NULL
Password_require_current: NULL
User_attributes: NULL

tables_priv 授权表 针对table有什么样的权限

 

 含义:user用户只有在本机host才可以连接数据库,是boot用户给的user用户的权限 在Timestamp的时候授权的 ,给某个表的Table_priv select权限 给某个Column_priv栏目权限。

columns_priv 栏目权限表 

select * from columns_priv;

 

3.MySQL权限控制

创建一个超级用户:

 

mysql 8.0 错误写法:

grant all privileges on *.* to yy@localhost identified by 'password' with grant option;
正确写法:

grant all privileges on *.* to yy@localhost with grant option;

8.0以前的版本需要在语句中添加identified by 密码;

8.0添加identified by 密码 会报错;

 

grant 授权

all privileges 所有的权限

on *.* 赋权限给  *.*    数据库.表  空的代表所有的 数据库.所有的表

to  loic@localhost  哪个用户和主机

identified by '123456' 密码是多少

with grant option 是不是对其他的用户授权

 

posted @ 2019-10-14 12:17  浮梦云烟  阅读(233)  评论(0)    收藏  举报