如何在MySQL / MariaDB中创建与root具有相同特权的用户?[关闭]


106

如何在MySQL / MariaDB中创建与root具有相同特权的用户?



Answers:


173
% mysql --user=root mysql
CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost' WITH GRANT OPTION;
CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%' WITH GRANT OPTION;
CREATE USER 'admin'@'localhost';
GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';
CREATE USER 'dummy'@'localhost';
FLUSH PRIVILEGES;

2
您能否详细说明创建原因'localhost''%'用户?
用户

3
仅在从本地主机连接时才能使用“ monty” @“ localhost”帐户。'monty'@'%'帐户的主机部分使用'%'通配符,因此可用于从任何主机进行连接
Takehin

@takeshin,%似乎没有包含localhost吗?
Pacerier


1
我必须运行$ mysql -u root -p,然后输入root密码才能启动MySQL命令行
user3405291
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.