mysql查当前用户的的命令_mysql命令大全用户管理相关命令
grant 普通數(shù)據(jù)用戶,查詢、插入、更新、刪除 數(shù)據(jù)庫(kù)中所有表數(shù)據(jù)的權(quán)利。
grant select on testdb.* to common_user@’%’
grant insert on testdb.* to common_user@’%’
grant update on testdb.* to common_user@’%’
grant delete on testdb.* to common_user@’%’
或者,用一條 MySQL 命令來(lái)替代:
grant select, insert, update, delete on testdb.* to common_user@’%’
9>.grant 數(shù)據(jù)庫(kù)開(kāi)發(fā)人員,創(chuàng)建表、索引、視圖、存儲(chǔ)過(guò)程、函數(shù)。。。等權(quán)限。
grant 創(chuàng)建、修改、刪除 MySQL 數(shù)據(jù)表結(jié)構(gòu)權(quán)限。
grant create on testdb.* to developer@’192.168.0.%’;
grant alter on testdb.* to developer@’192.168.0.%’;
grant drop on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 外鍵權(quán)限。
grant references on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 臨時(shí)表權(quán)限。
grant create temporary tables on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 索引權(quán)限。
grant index on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 視圖、查看視圖源代碼 權(quán)限。
grant create view on testdb.* to developer@’192.168.0.%’;
grant show view on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 存儲(chǔ)過(guò)程、函數(shù) 權(quán)限。
grant create routine on testdb.* to developer@’192.168.0.%’; -- now, can show procedure status
grant alter routine on testdb.* to developer@’192.168.0.%’; -- now, you can drop a procedure
grant execute on testdb.* to developer@’192.168.0.%’;
10>.grant 普通 DBA 管理某個(gè) MySQL 數(shù)據(jù)庫(kù)的權(quán)限。
grant all privileges on testdb to dba@’localhost’
其中,關(guān)鍵字 “privileges” 可以省略。
11>.grant 高級(jí) DBA 管理 MySQL 中所有數(shù)據(jù)庫(kù)的權(quán)限。
grant all on *.* to dba@’localhost’
12>.MySQL grant 權(quán)限,分別可以作用在多個(gè)層次上。
1. grant 作用在整個(gè) MySQL 服務(wù)器上:
grant select on *.* to dba@localhost; -- dba 可以查詢 MySQL 中所有數(shù)據(jù)庫(kù)中的表。
grant all on *.* to dba@localhost; -- dba 可以管理 MySQL 中的所有數(shù)據(jù)庫(kù)
2. grant 作用在單個(gè)數(shù)據(jù)庫(kù)上:
grant select on testdb.* to dba@localhost; -- dba 可以查詢 testdb 中的表。
3. grant 作用在單個(gè)數(shù)據(jù)表上:
grant select, insert, update, delete on testdb.orders to dba@localhost;
4. grant 作用在表中的列上:
grant select(id, se, rank) on testdb.apache_log to dba@localhost;
5. grant 作用在存儲(chǔ)過(guò)程、函數(shù)上:
grant execute on procedure testdb.pr_add to ’dba’@’localhost’
grant execute on function testdb.fn_add to ’dba’@’localhost’
注意:修改完權(quán)限以后 一定要刷新服務(wù),或者重啟服務(wù),刷新服務(wù)用:FLUSH PRIVILEGES。
權(quán)限
權(quán)限
說(shuō)明
all
alter
alter routine
使用alter procedure 和drop procedure
create
create routine
使用create ?procedure
create temporary tables
使用create temporary table
create ?user
create view
delete
drop
execute
使用call和存儲(chǔ)過(guò)程
file
使用select into outfile ?和load data infile
grant option
可以使用grant和revoke
index
可以使用create index 和drop index
insert
lock tables
鎖表
process
使用show full processlist
reload
使用flush
replication client
服務(wù)器位置訪問(wèn)
replocation slave
由復(fù)制從屬使用
select
show databases
show view
shutdown
使用mysqladmin shutdown 來(lái)關(guān)閉mysql
super
update
usage
無(wú)訪問(wèn)權(quán)限
13>密碼的哈希值可以使用password()函數(shù)獲取,如:
select password('123466');
所以在新建用戶的時(shí)候可以先查到hash值再建用戶:
grant select on *.* to 'zx_root'@'%' identified by '6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9';
14>create user創(chuàng)建的用戶沒(méi)有任何權(quán)限,還需要grant授權(quán),而grant不僅可以創(chuàng)建用戶,還可以在創(chuàng)建的同時(shí)對(duì)用戶授權(quán)
15、雞湯
root用戶密碼丟失的解決辦法:
mysql對(duì)于root用戶密碼丟失的情況采取了對(duì)應(yīng)的機(jī)制,可以通過(guò)特殊的方法登陸,然后在root下重新設(shè)置密碼
(1)使用--skip-grant-tables 選項(xiàng)啟動(dòng)mysql服務(wù),此選項(xiàng)啟動(dòng)后任何用戶都能訪問(wèn)數(shù)據(jù)庫(kù)
windows下 可以通過(guò)如下命令:
mysqld?--skip-grant-tables
或
mysqld-nt --skip-grant-tables
linux下
mysqld_safe --skip-grant-tables user=mysql
或
/etc/init.d/mysql start-mysqld--skip-grant-tables
啟動(dòng)后就可以通過(guò)root取登陸了
命令運(yùn)行后,用戶無(wú)法再當(dāng)前窗口輸入指令,此時(shí)打開(kāi)另外一個(gè)窗口,輸入不加密碼的登陸命令
mysql -u root
再進(jìn)行更新
在刷新下 flush privileges
關(guān)閉輸入--skip-grant-tables命令的窗口
總結(jié)
以上是生活随笔為你收集整理的mysql查当前用户的的命令_mysql命令大全用户管理相关命令的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: php 区块链算法_PoW/BFT等5种
- 下一篇: 被回收黄金的给骗了?回收黄金小心这些陷阱