MySQL创建用户并指定数据库权限

本地访问

创建一个“本地”用户并授权只能访问某个特定的数据库,这里的wxshop.* 表示数据库.表(*:所有表)


CREATE USER 'dev_wxshop'@'localhost' IDENTIFIED BY 'dev_wxshop';
GRANT SELECT, INSERT, UPDATE, REFERENCES, DELETE, CREATE, DROP, ALTER, INDEX, CREATE VIEW, SHOW VIEW ON `wxshop`.* TO 'dev_wxshop'@'localhost';
FLUSH PRIVILEGES;

任何服务器访问

创建一个“任何机器都可以访问”用户并授权只能访问某个特定的数据库


CREATE USER 'dev_wxshop'@'%' IDENTIFIED BY 'dev_wxshop';
GRANT SELECT, INSERT, UPDATE, REFERENCES, DELETE, CREATE, DROP, ALTER, INDEX, CREATE VIEW, SHOW VIEW ON `wxshop`.* TO 'dev_wxshop'@'%';
FLUSH PRIVILEGES;

你可能感兴趣的:(MySQL)