首页 > 代码库 > 【SQL篇章--基于MySQL5.7--创建用户】

【SQL篇章--基于MySQL5.7--创建用户】

SQL:
 
创建用户:>=MySQL5.7.6
查看用户:
mysql> select user,host,authentication_string from mysql.user;
ALTER USER:
ALTER USER [IF EXISTS]USER() IDENTIFIED BY ‘auth_string‘;
 
ADDING USER ACCOUNT:
CREATE USER ‘finley‘@‘localhost‘ IDENTIFIED BY ‘some_pass‘; GRANT ALL PRIVILEGES ON *.* TO ‘finley‘@‘localhost‘ WITH GRANT OPTION;
CREATE USER ‘finley‘@‘%‘ IDENTIFIED BY ‘some_pass‘; GRANT ALL PRIVILEGES ON *.* TO ‘finley‘@‘%‘ WITH GRANT OPTION;
mysql> CREATE USER ‘admin‘@‘localhost‘ IDENTIFIED BY ‘admin_pass‘;
mysql> GRANT RELOAD,PROCESS ON *.* TO ‘admin‘@‘localhost‘;
mysql> CREATE USER ‘dummy‘@‘localhost‘;
 
mysql> SHOW CREATE USER ‘admin‘@‘localhost‘\G
*************************** 1. row ***************************
CREATE USER for admin@localhost:
CREATE USER ‘admin‘@‘localhost‘ IDENTIFIED WITH ‘mysql_native_password‘ AS ‘*67ACDEBDAB923990001F0FFB017EB8ED41861105‘ REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK
 
 
DROP USER:
DROP USER ‘jeffrey‘@‘localhost‘;

【SQL篇章--基于MySQL5.7--创建用户】