mysql⽤户表字段_MySQL⽤户、[表库字段]权限、管理及查询
缓存详解
MySQL⽤户管理:mysql> help contents;
You asked for help about help category: "Contents"
For more information, type 'help ', where is one of the following
categories:
Account Management
Administration
Compound Statements
Data Definition
Data Manipulation
Data Types
Functions
Functions and Modifiers for Use with GROUP BY
Geographic Features
Help Metadata
Language Structure
Plugins
Procedures
Storage Engines
Table Maintenance
Transactions
User-Defined Functions
Utility
*************
mysql> help Account Management;
You asked for help about help category: "Account Management"
For more information, type 'help ', where is one of the following
topics:
CREATE USER
DROP USER
GRANT
RENAME USER
REVOKE
SET PASSWORD
⽤户帐号:username@hostname, password
⽤户帐号管理:
CREATE USER
DROP UESER
RENAME USER 修改⽤户名称
SET PASSWORD
权限管理:
GRANT 如果⽤户不存在 ,可以同时创建⽤户
REVOKE
【CREATE USER】
CREATE USER username@hostname
[随机数发生器种子
IDENTIFIED BY [PASSWORD] 'password'
]
主机也可使⽤通配符:
%:
_:
testuser@'172.16.100.1__' 这就是下⾯的地址范围
172.16.100.100-172.16.100.199
【创建testuser ⽤户,限制在192.168.6.0/24 ⽹段内,密码是testpass】
【查看⽤户能够使⽤的权限】:SHOW GRANTS FOR
username@'hostname'mysql> SHOW GRANTS FOR 'testuser'@'192.168.6.%' \G
霹雳布袋戏最新国语版*************************** 1. row ***************************
Grants for testuser@192.168.6.%: GRANT USAGE ON *.* TO 'testuser'@'192.168.6.%' IDENTIFIED BY PASSWORD
1 row in set (0.00 sec)
mysql> create user testuser@'192.168.6.%' identified by 'testpass';
Query OK, 0 rows affected (0.00 sec)
【通知重读授权表】mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
【打开⼀个终端2,⽤testuser 远程访问mysql服务器192.168.6.177】[root@pc0003 ~]# mysql -u testuser -h 192.168.6.177 -p
Enter password:
【终端2此时什么库也看不到】mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+
2 rows in set (0.02 sec)
【 information_schema】mysql> show tables from information_schema;
mysql共享信息,关机就清空,相当于linux的/proc
【终端2 尝试创建⼀个库,提⽰没有权限】mysql> create database testdb;
ERROR 1044 (42000): Access denied for user 'testuser'@'192.168.6.%' to database 'testdb'
【Ranme User】终端2⾃⼰没有权限给⾃⼰改名mysql> rename user 'testuser'@'192.168.6.%' to 'tuser'@'192.168.6.%'; ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation
【给有权限的⽤户来操作】mysql> rename user 'testuser'@'192.168.6.%' to 'tuser'@'192.168.6.%';
Query OK, 0 rows affected (0.01 sec)
【】
此时终端2没有任何变化,必须退出重新登录才能或得更改的效果。
【终端2 以新的⽤户名,旧的密码就可以登录了】[root@pc0003 ~]# mysql -u tuser -h 192.168.6.177 -p
Enter password:
【修改密码】mysql> help set password;SET PASSWORD FOR 'bob'@'%.' = PASSWORD('cleartext password');【授权】mysql> help grant;
mysql是什么系统【显⽰服务器当前所有线程】mysql> show processlist \G
*************************** 1. row ***************************
Id: 1
User: root
Host: localhost
db: NULL
Command: Query
Time: 0
State: NULL
Info: show processlist
*************************** 2. row ***************************
Id: 7
User: tuser
Host: 192.168.6.177:52151
db: NULL
Command: Sleep
Time: 12
State:
Info: NULL
2 rows in set (0.00 sec)
【查看谁在登录我的mysql】mysql> use hellodb; Database changed
mysql> lock tables classes read;
jquery中ajax是什么Query OK, 0 rows affected (0.01 sec)
mysql> show processlist \G
*************************** 1. row *************************** Id: 1
User: root
Host: localhost
db: hellodb
Command: Querydefillama
Time: 0
State: NULL
Info: show processlist
*************************** 2. row *************************** Id: 7
User: tuser
Host: 192.168.6.177:52151
db: NULL
Command: Sleep
Time: 165
State:
Info: NULL
2 rows in set (0.00 sec)
【MySQL的权限类别:】
库级别
表级别
字段级别
管理类
程序类
管理类权限:
CREATE TEMPORARY TABLES CREATE USER
FILE
SUPER
SHOW DATABASES
RELOAD
SHUTDOWN
REPLICATION SLAVE REPLICATION CLIENT
LOCK TABLES
PROCESS
库级别和表级别:
ALTER
ALTER ROUTINE
springbean的装配方式CREATE
CREATE ROUTINE
CREATE VIEW
DROP
EXECUTE
GRNAT OPTION
INDEX
SHOW VIEW
数据操作(表级别):
SELECT
INSERT
UPDATE
DELETE
字段级别:
SELECT(col1,...)
UPDATE(col1,...)
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论