當前位置:首頁 » 操作系統 » 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用戶並不能刪除用戶。

熱點內容
單片機android 發布:2024-09-20 09:07:24 瀏覽:759
如何提高三星a7安卓版本 發布:2024-09-20 08:42:35 瀏覽:659
如何更換伺服器網站 發布:2024-09-20 08:42:34 瀏覽:306
子彈演算法 發布:2024-09-20 08:41:55 瀏覽:284
手機版網易我的世界伺服器推薦 發布:2024-09-20 08:41:52 瀏覽:812
安卓x7怎麼邊打游戲邊看視頻 發布:2024-09-20 08:41:52 瀏覽:158
sql資料庫安全 發布:2024-09-20 08:31:32 瀏覽:89
蘋果連接id伺服器出錯是怎麼回事 發布:2024-09-20 08:01:07 瀏覽:503
編程鍵是什麼 發布:2024-09-20 07:52:47 瀏覽:655
學考密碼重置要求的證件是什麼 發布:2024-09-20 07:19:46 瀏覽:479