知乎專欄 | 多維度架構 |
目錄
CREATE USER user [IDENTIFIED BY [PASSWORD] 'password'] [, user [IDENTIFIED BY [PASSWORD] 'password']] ...
CREATE USER 'test'@'xxx.xxx.xxx.xxx' IDENTIFIED BY 'your_password';
CREATE USER 'root'@'192.168.1.%' IDENTIFIED BY 'password';
add a new user by grant
GRANT ALL PRIVILEGES ON opencart.* TO 'neo'@'localhost' IDENTIFIED BY 'chen' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON *.* TO 'neo'@'localhost' IDENTIFIED BY 'chen' WITH GRANT OPTION; FLUSH PRIVILEGES;
MySQL 8.0
mysql> CREATE USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'pMQiEge1ikst7S_6tlXzBOmt_4b'; Query OK, 0 rows affected (0.06 sec) mysql> grant all on *.* to 'root'@'%'; Query OK, 0 rows affected (0.11 sec)
DROP USER user [, user] ...
mysql> drop user 'root'@'%'; Query OK, 0 rows affected (0.02 sec) mysql> drop user admin@'localhost'; Query OK, 0 rows affected (0.00 sec) mysql> drop user admin@'127.0.0.1'; Query OK, 0 rows affected (0.00 sec)