当前位置:首页 » 操作系统 » mysql数据库权限

mysql数据库权限

发布时间: 2022-02-17 13:25:12

⑴ 怎么查看mysql数据库的权限

数据库的权限?应该是用户的权限,直接查询mysql数据库下users表,里面有记录。

⑵ mysql怎么给数据库添加权限

可以用phpMyAdmin通过输入语句的方法建立用户,或者一般的图形界面的SQL管理程序也可以建立和编辑用户.
这里只说使用GRANT语句的方法,当然还有直接修改MySQL表的方法,不过很麻烦,用的人不多~
前提是有MySQL root权限
例子:建立另一个超级用户(所有权限)的方法
GRANT ALL ON *.* TO username@localhost IDENTIFIED BY 'password' WITH GRANT OPTION
localhost是主机名,也可以是IP,用于限定这个用户是否可以远程连接.还可以用通配符"%",比如%.im286.com,或者202.97.224.%
*.* 中第一个星星是数据库名(*为所有数据库),第二个星星是表名(*为前面数据库下的所有表)
ALL 是指全部语句的操作权限(经常看到虚拟主机等的用户没有DROP权限,就是这里做了手脚)
语法大概就是这样吧.

⑶ 如何更改mysql数据库用户权限

1,要授予的权限
2,被授予访问权限的数据库或表
3,用户名
grant和revoke可以在几个层次上控制访问权限
1,整个服务器,使用 grant ALL 和revoke ALL
2,整个数据库,使用on database.*
3,特点表,使用on database.table
4,特定的列
5,特定的存储过程

⑷ 如何设置mysql的权限为所有的用户权限

这个设置只要进入 linux 系统的超级用户状态 # 下面,即可以使用 chmod 命令对 MySQL 数据库系统下面的所有文件进行权限设置。具体的就看你想设置成什么权限,你就可以设置成什么权限了。chmod 的基本用法如下:
#chmod 750 myfile <cr>
该命令对 myfile 这个文件设置成:文件所有者(头 3 位)具有:可读(4)、可写(2)、可执行(1)权限;同组用户(中间 3 位)具有:可读(4)、可执行(1)权限;其他用户(后 3 位):不可读(4)、不可写(2)、不可执行(1)权限。
关于 chmod 更多的参数,你可以使用 man chmod 命令进行查看。

⑸ MySQL的权限有哪些

MySQL各种权限(共27个)
(以下操作都是以root身份登陆进行grant授权,以p1@localhost身份登陆执行各种命令。)
1. usage
连接(登陆)权限,建立一个用户,就会自动授予其usage权限(默认授予)。
mysql> grant usage on *.* to ‘p1′@’localhost’ identified by ‘123′;
该权限只能用于数据库登陆,不能执行任何操作;且usage权限不能被回收,也即REVOKE用户并不能删除用户。
2. select
必须有select的权限,才可以使用select table
mysql> grant select on pyt.* to ‘p1′@’localhost’;
mysql> select * from shop;
3. create
必须有create的权限,才可以使用create table
mysql> grant create on pyt.* to ‘p1′@’localhost’;
4. create routine
必须具有create routine的权限,才可以使用{create |alter|drop} {procere|function}
mysql> grant create routine on pyt.* to ‘p1′@’localhost’;
当授予create routine时,自动授予EXECUTE, ALTER ROUTINE权限给它的创建者:
mysql> show grants for ‘p1′@’localhost’;
+—————————————————————————+
Grants for p1@localhost
+————————————————————————–+
| GRANT USAGE ON *.* TO ‘p1′@’localhost’ IDENTIFIED BY PASSWORD ‘*′ |
| GRANT SELECT, CREATE, CREATE ROUTINE ON `pyt`.* TO ‘p1′@’localhost’|
| GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `pyt`.`pro_shop1` TO ‘p1′@’localhost’ |
+————————————————————————————-+
5. create temporary tables(注意这里是tables,不是table)
必须有create temporary tables的权限,才可以使用create temporary tables.
mysql> grant create temporary tables on pyt.* to ‘p1′@’localhost’;
[mysql@mydev ~]$ mysql -h localhost -u p1 -p pyt
mysql> create temporary table tt1(id int);
6. create view
必须有create view的权限,才可以使用create view
mysql> grant create view on pyt.* to ‘p1′@’localhost’;
mysql> create view v_shop as select price from shop;
7. create user
要使用CREATE USER,必须拥有mysql数据库的全局CREATE USER权限,或拥有INSERT权限。
mysql> grant create user on *.* to ‘p1′@’localhost’;
或:mysql> grant insert on *.* to p1@localhost;
8. insert
必须有insert的权限,才可以使用insert into ….. values….
9. alter
必须有alter的权限,才可以使用alter table
alter table shop modify dealer char(15);
10. alter routine
必须具有alter routine的权限,才可以使用{alter |drop} {procere|function}
mysql>grant alter routine on pyt.* to ‘p1′@’ localhost ‘;
mysql> drop procere pro_shop;
Query OK, 0 rows affected (0.00 sec)

mysql> revoke alter routine on pyt.* from ‘p1′@’localhost’;
[mysql@mydev ~]$ mysql -h localhost -u p1 -p pyt
mysql> drop procere pro_shop;
ERROR 1370 (42000): alter routine command denied to user ‘p1′@’localhost’ for routine ‘pyt.pro_shop’
11. update
必须有update的权限,才可以使用update table
mysql> update shop set price=3.5 where article=0001 and dealer=’A';
12. delete
必须有delete的权限,才可以使用delete from ….where….(删除表中的记录)
13. drop
必须有drop的权限,才可以使用drop database db_name; drop table tab_name;
drop view vi_name; drop index in_name;
14. show database
通过show database只能看到你拥有的某些权限的数据库,除非你拥有全局SHOW DATABASES权限。
对于p1@localhost用户来说,没有对mysql数据库的权限,所以以此身份登陆查询时,无法看到mysql数据库:
mysql> show databases;
+——————–+
| Database |
+——————–+
| information_schema|
| pyt |
| test |
+——————–+
15. show view
必须拥有show view权限,才能执行show create view。
mysql> grant show view on pyt.* to p1@localhost;
mysql> show create view v_shop;
16. index
必须拥有index权限,才能执行[create |drop] index
mysql> grant index on pyt.* to p1@localhost;
mysql> create index ix_shop on shop(article);
mysql> drop index ix_shop on shop;
17. excute
执行存在的Functions,Proceres
mysql> call pro_shop1(0001,@a);
+———+
| article |
+———+
| 0001 |
| 0001 |
+———+
mysql> select @a;
+——+
| @a |
+——+
| 2 |
+——+
18. lock tables
必须拥有lock tables权限,才可以使用lock tables
mysql> grant lock tables on pyt.* to p1@localhost;
mysql> lock tables a1 read;
mysql> unlock tables;
19. references
有了REFERENCES权限,用户就可以将其它表的一个字段作为某一个表的外键约束。
20. reload
必须拥有reload权限,才可以执行flush [tables | logs | privileges]
mysql> grant reload on pyt.* to p1@localhost;
ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
mysql> grant reload on *.* to ‘p1′@’localhost’;
Query OK, 0 rows affected (0.00 sec)
mysql> flush tables;
21. replication client
拥有此权限可以查询master server、slave server状态。
mysql> show master status;
ERROR 1227 (42000): Access denied; you need the SUPER,REPLICATION CLIENT privilege for this operation
mysql> grant Replication client on *.* to p1@localhost;
或:mysql> grant super on *.* to p1@localhost;
mysql> show master status;
+——————+———-+————–+——————+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+——————+———-+————–+——————+
| mysql-bin.000006 | 2111 | | |
+——————+———-+————–+——————+
mysql> show slave status;
22. replication slave
拥有此权限可以查看从服务器,从主服务器读取二进制日志。
mysql> show slave hosts;
ERROR 1227 (42000): Access denied; you need the REPLICATION SLAVE privilege for this operation
mysql> show binlog events;
ERROR 1227 (42000): Access denied; you need the REPLICATION SLAVE privilege for this operation
mysql> grant replication slave on *.* to p1@localhost;
mysql> show slave hosts;
Empty set (0.00 sec)
mysql>show binlog events;
+—————+——-+—————-+———–+————-+————–+
| Log_name | Pos | Event_type | Server_id| End_log_pos|Info | +—————+——-+————–+———–+————-+—————+
| mysql-bin.000005 | 4 | Format_desc | 1 | 98 | Server ver: 5.0.77-log, Binlog ver: 4 | |mysql-bin.000005|98|Query|1|197|use `mysql`; create table a1(i int)engine=myisam|
……………………………………
23. Shutdown
关闭MySQL:
[mysql@mydev ~]$ mysqladmin shutdown
重新连接:
[mysql@mydev ~]$ mysql
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
[mysql@mydev ~]$ cd /u01/mysql/bin
[mysql@mydev bin]$ ./mysqld_safe &
[mysql@mydev bin]$ mysql
24. grant option
拥有grant option,就可以将自己拥有的权限授予其他用户(仅限于自己已经拥有的权限)
mysql> grant Grant option on pyt.* to p1@localhost;
mysql> grant select on pyt.* to p2@localhost;
25. file
拥有file权限才可以执行 select ..into outfile和load data infile…操作,但是不要把file, process, super权限授予管理员以外的账号,这样存在严重的安全隐患。
mysql> grant file on *.* to p1@localhost;
mysql> load data infile ‘/home/mysql/pet.txt’ into table pet;
26. super
这个权限允许用户终止任何查询;修改全局变量的SET语句;使用CHANGE MASTER,PURGE MASTER LOGS。
mysql> grant super on *.* to p1@localhost;
mysql> purge master logs before ‘mysql-bin.000006′;
27. process
通过这个权限,用户可以执行SHOW PROCESSLIST和KILL命令。默认情况下,每个用户都可以执行SHOW PROCESSLIST命令,但是只能查询本用户的进程。
mysql> show processlist;
+—-+——+———–+——+———+——+——-+——————+
| Id | User | Host | db | Command | Time | State | Info |
+—-+——+———–+——+———+——+——-+——————+
| 12 | p1 | localhost | pyt | Query | 0 | NULL | show processlist |
+—-+——+———–+——+———+——+——-+——————+
另外,
管理权限(如 super, process, file等)不能够指定某个数据库,on后面必须跟*.*
mysql> grant super on pyt.* to p1@localhost;
ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
mysql> grant super on *.* to p1@localhost;
Query OK, 0 rows affected (0.01 sec)

⑹ mysql创建数据库需要什么权限

你都不是安全登录的,没有建库的权限,重新退出mysql,
在cmd下执行 mysql -u root -p密码<img id="selectsearch-icon" src="https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/iknow/qb/select-search.png" alt="搜索">

⑺ mysql数据库目录访问权限

1、是操作系统级别用户权限,直接找到安装mysql和数据库文件的目录右键安全属性调整

2、如果是数据库级别的,可以直接找到数据库中的用户选项调整权限级别

⑻ linux mysql 数据库权限

hi 楼主,在数据库中创建包含很多,视图,索引,临时表的创建权限都能分开赋予,你可以执行 show privileges 来查看权限参数,我这边就以创建表为例,只包含查询表功能,其他修改,删除,备份没有权限;以下是步骤:
1,create user 'tom'@'%' identified by '123456';---创建用户,无权限;
2, grant create,select on wangxh2.* to tom;-----把wangxh2库的所有表的创建和查询赋予tom
3,flush privileges;-----刷新权限表才能起效
接下来是测试:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
| wangxh2 |
+--------------------+
3 rows in set (0.06 sec)

mysql> use wangxh2
Database changed
mysql> show tables;
+-------------------+
| Tables_in_wangxh2 |
+-------------------+
| test |
+-------------------+
1 row in set (0.00 sec)

mysql> drop test;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'test' at line 1
mysql> drop table test;
ERROR 1142 (42000): DROP command denied to user 'tom'@'localhost' for table 'test'
mysql> select count(*) from test;
+----------+
| count(*) |
+----------+
| 33554432 |
+----------+
1 row in set (0.01 sec)

mysql> insert into test values(1);
ERROR 1142 (42000): INSERT command denied to user 'tom'@'localhost' for table 'test'
mysql> delete from test;
ERROR 1142 (42000): DELETE command denied to user 'tom'@'localhost' for table 'test'
mysql> update test set id=1;
ERROR 1142 (42000): UPDATE command denied to user 'tom'@'localhost' for table 'test'
mysql> create table test1 (id int);
Query OK, 0 rows affected (0.02 sec)

mysql> insert into test1 values(1);
ERROR 1142 (42000): INSERT command denied to user 'tom'@'localhost' for table 'test1'

[mysql@localhost ~]$ mysqlmp -u tom -paidengshan wangxh2 >/home/mysql/aa.sql
mysqlmp: Got error: 1044: Access denied for user 'tom'@'%' to database 'wangxh2' when using LOCK TABLES
[mysql@localhost ~]$
-----------------------------------------------------------------------------------------

以上测试发现,tom对wangxh2有建表,查询表的权限,但是修改,删除,新增,备份都没有权限,达到你的需求了

⑼ mysql数据库全局权限什么意思

一.权限表
mysql数据库中的3个权限表:user 、db、 host
权限表的存取过程是:
1)先从user表中的host、 user、 password这3个字段中判断连接的IP、用户名、密码是否存在表中,存在则通过身份验证;
2)通过权限验证,进行权限分配时,按照useràdbàtables_privàcolumns_priv的顺序进行分配。即先检查全局权限表user,如果user中对应的权限为Y,则此用户对所有数据库的权限都为Y,将不再检查db, tables_priv,columns_priv;如果为N,则到db表中检查此用户对应的具体数据库,并得到db中为Y的权限;如果db中为N,则检查tables_priv中此数据库对应的具体表,取得表中的权限Y,以此类推。
二.MySQL各种权限(共27个)
(以下操作都是以root身份登陆进行grant授权,以p1@localhost身份登陆执行各种命令。)
1. usage
连接(登陆)权限,建立一个用户,就会自动授予其usage权限(默认授予)。
mysql> grant usage on *.* to ‘p1′@’localhost’ identified by ‘123′;
该权限只能用于数据库登陆,不能执行任何操作;且usage权限不能被回收,也即REVOKE用户并不能删除用户。

热点内容
学考密码重置要求的证件是什么 发布:2024-09-20 07:19:46 浏览:476
电脑主服务器怎么开机 发布:2024-09-20 07:19:07 浏览:727
2022款瑞虎升级哪些配置 发布:2024-09-20 06:59:07 浏览:263
数据库与asp 发布:2024-09-20 06:55:25 浏览:726
python解释编译 发布:2024-09-20 06:52:57 浏览:647
舞蹈丰收脚本 发布:2024-09-20 06:36:26 浏览:595
linux进程端口号 发布:2024-09-20 06:36:11 浏览:79
派派怎么改密码忘了 发布:2024-09-20 06:25:49 浏览:780
linux虚拟地址物理地址 发布:2024-09-20 06:23:29 浏览:564
大华监控云存储 发布:2024-09-20 06:13:24 浏览:597