MYSQL创建数据库并分权限给用户

/* 创建数据库db0 */

CREATE DATABASE db0 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

/*授权给用户名为user,密码为password的任何主机登录操作*/

grant all privileges on db0.* to user@'%' identified by 'password';

/*授权ip为172.16.16.122的电脑可以使用用户名为user,密码为password登录操作*/

grant all privileges on db0.* to user@'172.16.16.122' identified by 'password';

/*授权给用户名为user,密码为password的本地主机登录操作*/

grant all privileges on db0.* to user@localhost identified by 'password';

/*撤销用户权限*/

REVOKE all privileges on db0.* from user@'%';

你可能感兴趣的:(数据库知识)