linux mysql 對使用者的基本操作。。

2021-08-28 17:34:28 字數 1303 閱讀 1213

登入:

mysql -u username -p

顯示所有的資料庫:

show databases;

使用某乙個資料庫:

use databasename;

顯示乙個資料庫的所有表:

show tables;

退出:quit;

刪除資料庫和資料表

mysql>drop database 資料庫名;

mysql>drop table 資料表名;

檢視所有的使用者:

select distinct concat('user: ''',user,'''@''',host,''';') as query from mysql.user;

新建使用者:

create user'dog'@'localhost'identified by'123456';

為使用者授權:

格式:grant 許可權 on 資料庫.* to 使用者名稱@登入主機 identified by "密碼";

示例:grant all privileges on testdb.* to test@localhost identified by '1234';

然後需要執行重新整理許可權的命令:

flush privileges;

為使用者授予部分許可權:

grant select,update on testdb.* to test@localhost identified by '1234';

授予乙個使用者所有資料庫的某些許可權:

grant select,delete,update,create,drop on *.* to test@"%" identified by "1234";

刪除使用者:

delete from user where user='test' and host='localhost';

然後重新整理許可權;

刪除賬戶及許可權:>drop user 使用者名稱@'%';

>drop user 使用者名稱@ localhost; 

修改指定使用者密碼

使用root登入:

mysql -u root -p

執行命令:

update mysql.user set password=password('新密碼') where user="test" and host="localhost";

重新整理許可權:

flush privileges;

linux mysql使用者管理

一 root使用者密碼的維護 由於安裝mysql完後,mysql會自動提供乙個不帶密碼的root使用者,為了安全起見給root設定密碼 mysqladmin u root password 123 123為密碼,也可以寫成 123 或 123 設定密碼後登入時就不能直接輸入mysql了,必須跟些引數...

linux mysql新增使用者

格式 grant select on 資料庫.to 使用者名稱 登入主機 identified by 密碼 例1 增加乙個使用者user 1密碼為123,讓他可以在任何主機上登入,並對所有資料庫有查詢 插入 修改 刪除的許可權。首先用以root使用者連入mysql,然後鍵入以下命令 mysql gr...

Linux mysql使用者及使用者許可權管理

mysql u root p 管理員root登入mysql 1.增加使用者host 指定該使用者在哪個主機上可以登陸 如果是本地使用者可用localhost 如果想讓該使用者可以從任意遠端主機登陸,可以使用萬用字元 create user 使用者名稱 identified by 密碼 所有主機可登入...