0.
https://dev.mysql.com/doc/refman/5.6/en/creating-accounts.html
1.创建用户
CREATE 用户名IDENTIFIED BY 密码;
CREATE USER test IDENTIFIED BY 'test';
2.授予权限
GRANT 权限名字 数据库.表 TO user;
GRANT ALL ON db1.* TO 'test'@'%';
2.1创建用户并授予权限
CREATE USER 'test'@'%' IDENTIFIED BY 'test';
GRANT ALL ON db1.* TO 'test'@'%' WITH GRANT OPTION;
3.创建数据库
CREATE DATABASE db1 CHARACTER SET utf8;
4.测试链接
FLUSH PRIVILEGES;
navicat 或者 mysql -u test -p -h 主机
官网:
https://dev.mysql.com/doc/refman/5.6/en/creating-accounts.html
创建账号并授予某个db所有权限
CREATE USER 'custom'@'localhost'
IDENTIFIED BY 'password';
GRANT ALL
ON bankaccount.*
TO 'custom'@'localhost';
创建账号并授予某个db 部分权限
CREATE USER 'custom'@'%'
IDENTIFIED BY 'password';
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
ON expenses.*
TO 'custom'@'host47.example.com';
删除账号
DROP USER 'finley'@'localhost';