mysql刪除用戶的所有許可權
1. MySQL如何查看,刪除用戶
1.查看所有用戶(需要在root用戶下進行)
select host,user,password from mysql.user;
2.刪除用戶
mysql>Delete FROM user Where User='用戶名版' and Host='上圖有個host列表權所示';//刪除用戶
例:mysql>Delete FROM user Where User='yl' and Host='localhost';
mysql>flush privileges; //刷新許可權
mysql>drop database ylDB; //刪除用戶的資料庫
2. mysql怎麼刪除一個用戶的許可權
這樣才對 revoke all from userName
3. mysql資料庫關於創建和刪除用戶的問題
1.新建用戶
登錄MYSQL:
@>mysql -u root -p
@>密碼
創建用戶:
mysql> insert into mysql.user(Host,User,Password) values("localhost","test",password("1234"));
這樣就創建了一個名為:test 密碼為:1234 的用戶。
注意:此處的"localhost",是指該用戶只能在本地登錄,不能在另外一台機器上遠程登錄。如果想遠程登錄的話,將"localhost"改為"%",表示在任何一台電腦上都可以登錄。也可以指定某台機器可以遠程登錄。
然後登錄一下:
mysql>exit;
@>mysql -u test -p
@>輸入密碼
mysql>登錄成功
2.為用戶授權
授權格式:grant 許可權 on 資料庫.* to 用戶名@登錄主機 identified by "密碼";
登錄MYSQL(有ROOT許可權),這里以ROOT身份登錄:
@>mysql -u root -p
@>密碼
首先為用戶創建一個資料庫(testDB):
mysql>create database testDB;
授權test用戶擁有testDB資料庫的所有權限(某個資料庫的所有許可權):
mysql>grant all privileges on testDB.* to test@localhost identified by '1234';
mysql>flush privileges;//刷新系統許可權表
格式:grant 許可權 on 資料庫.* to 用戶名@登錄主機 identified by "密碼";
如果想指定部分許可權給一用戶,可以這樣來寫:
mysql>grant select,update on testDB.* to test@localhost identified by '1234';
mysql>flush privileges; //刷新系統許可權表
授權test用戶擁有所有資料庫的某些許可權:
mysql>grant select,delete,update,create,drop on *.* to test@"%" identified by "1234";
//test用戶對所有資料庫都有select,delete,update,create,drop 許可權。
//@"%" 表示對所有非本地主機授權,不包括localhost。(localhost地址設為127.0.0.1,如果設為真實的本地地址,不知道是否可以,沒有驗證。)
//對localhost授權:加上一句grant all privileges on testDB.* to test@localhost identified by '1234';即可。
3.刪除用戶
@>mysql -u root -p
@>密碼
mysql>Delete FROM user Where User='test' and Host='localhost';
mysql>flush privileges;
mysql>drop database testDB; //刪除用戶的資料庫
刪除賬戶及許可權:>drop user 用戶名@'%';
>drop user 用戶名@ localhost;
4.修改指定用戶密碼
@>mysql -u root -p
@>密碼
mysql>update mysql.user set password=password('新密碼') where User="test" and Host="localhost";
mysql>flush privileges;
5.列出所有資料庫
mysql>show databases;
6.切換資料庫
mysql>use '資料庫名';
7.列出所有表
mysql>show tables;
8.顯示數據表結構
mysql>describe 表名;
9.刪除資料庫和數據表
mysql>drop database 資料庫名;
mysql>drop table 數據表名;
4. mysql怎麼刪除賬戶
MySql中添加用戶,新建資料庫,用戶授權,刪除用戶,修改密碼(注意每行後邊都跟個;表示一個命令語句結束):
1.新建用戶
登錄MYSQL:
@>mysql -u root -p
@>密碼
創建用戶:
mysql> insert into mysql.user(Host,User,Password) values("localhost","test",password("1234"));
這樣就創建了一個名為:test 密碼為:1234 的用戶。
注意:此處的"localhost",是指該用戶只能在本地登錄,不能在另外一台機器上遠程登錄。如果想遠程登錄的話,將"localhost"改為"%",表示在任何一台電腦上都可以登錄。也可以指定某台機器可以遠程登錄。
然後登錄一下:
mysql>exit;
@>mysql -u test -p
@>輸入密碼
mysql>登錄成功
2.為用戶授權
授權格式:grant 許可權 on 資料庫.* to 用戶名@登錄主機 identified by "密碼";
登錄MYSQL(有ROOT許可權),這里以ROOT身份登錄:
@>mysql -u root -p
@>密碼
首先為用戶創建一個資料庫(testDB):
mysql>create database testDB;
授權test用戶擁有testDB資料庫的所有許可權(某個資料庫的所有許可權):
mysql>grant all privileges on testDB.* to test@localhost identified by '1234';
mysql>flush privileges;//刷新系統許可權表
格式:grant 許可權 on 資料庫.* to 用戶名@登錄主機 identified by "密碼";
如果想指定部分許可權給一用戶,可以這樣來寫:
mysql>grant select,update on testDB.* to test@localhost identified by '1234';
mysql>flush privileges; //刷新系統許可權表
授權test用戶擁有所有資料庫的某些許可權:
mysql>grant select,delete,update,create,drop on *.* to test@"%" identified by "1234";
//test用戶對所有資料庫都有select,delete,update,create,drop 許可權。
//@"%" 表示對所有非本地主機授權,不包括localhost。(localhost地址設為127.0.0.1,如果設為真實的本地地址,不知道是否可以,沒有驗證。)
//對localhost授權:加上一句grant all privileges on testDB.* to test@localhost identified by '1234';即可。
3.刪除用戶
@>mysql -u root -p
@>密碼
mysql>Delete FROM user Where User='test' and Host='localhost';
mysql>flush privileges;
mysql>drop database testDB; //刪除用戶的資料庫
刪除賬戶及許可權:>drop user 用戶名@'%';
>drop user 用戶名@ localhost;
4.修改指定用戶密碼
@>mysql -u root -p
@>密碼
mysql>update mysql.user set password=password('新密碼') where User="test" and Host="localhost";
mysql>flush privileges;
5.列出所有資料庫
mysql>show database;
6.切換資料庫
mysql>use '資料庫名';
7.列出所有表
mysql>show tables;
8.顯示數據表結構
mysql>describe 表名;
9.刪除資料庫和數據表
mysql>drop database 資料庫名;
mysql>drop table 數據表名;
5. 怎麼刪除mysql用戶
刪除用戶抄
@>mysql
-u
root
-p
@>密碼
mysql>Delete
FROM
user
Where
User='test'
and
Host='
localhost
';
mysql>flush
privileges;
mysql>drop
database
testDB;
//刪除用戶的資料庫
刪除賬戶及許可權:>drop
user
用戶名@'%';
>drop
user
用戶名@
localhost;
6. mysql 怎麼刪除用戶
刪除用戶步驟如下:
第一步:用root用戶登錄「mysql
-u
root
-p」之後輸入密碼回車。
第二步:專刪除用戶「mysql>Delete
FROM
user
Where
User='test'
。
備注屬:上面的意思就是從系統user表中刪除用戶名為「test」用戶。
7. mysql 用drop和delete方法刪除用戶的區別
(方法一)drop
user
用戶名;
語法:drop
user
用戶名;
作用:刪除已經存在的用戶,例如要刪除yan這個用戶,(drop
user
yan;)默認刪除的是yan@"%"這個用戶,如果還有其他用戶,例如yan@"localhost",yan@"ip",則不會一起被刪除。如果只存在一個用戶yan@"localhost",使用語句(drop
user
yan;)會報錯,應該用(drop
user
yan@"localhost";)如果不能確定(用戶名@機器名)中的機器名,可以在mysql中的user表中進行查找,user列對應的是用戶名,host列對應的是機器名。
(方法二)delete
from
user
where
user="用戶名"
and
host="localhost";
delete也是刪除用戶的方法,例如要刪除yan@"localhost"用戶,則可以(delete
from
user
where
user="yan"
and
host="localhost";)
註:drop刪除掉的用戶不僅將user表中的數據刪除,還會刪除諸如db和其他許可權表的內容。而(方法二)只是刪除了user表的內容,其他表不會被刪除,後期如果命名一個和已刪除用戶相同的名字,許可權就會被繼承。
8. mysql里有多個用戶 怎麼查看這幾個用戶的修改刪除操作行為
登錄mysql後;
1、輸入use mysql ;
2、輸入select user , update_priv ,delete_priv ; 顯示N為沒有有許可權顯示Y有許可權。
9. mysql 刪除一條root@localhost的許可權後 丟失所有許可權
下次不用那麼麻煩,從其他地方拷貝mysql data 目錄下的mysql 文件夾 覆蓋 重啟就ok了,所有的許可權管理都在data文件夾下mysql中,如果有很多用戶才會啟動安全模式恢復root密碼
10. 如何關閉mysql遠程登錄許可權
1、本地登錄到mysql資料庫,mysql -uroot -p。