1,为添加用户的的实例,用户名为dc3688,密码为123456,并授权用户可进行 SELECT, INSERT 和 UPDATE操作权限
root@host# mysql -u root -p
Enter password:*******
mysql> use mysql;
Database changed
INSERT INTO user
(host, user, password,
select_priv, insert_priv, update_priv)
VALUES (‘localhost‘, ‘guest‘,
PASSWORD(‘guest123‘), ‘Y‘, ‘Y‘, ‘Y‘);
y表示yes
最后 用命令 重载一下 FLUSH PRIVILEGES;
2, 添加用户的方法为通过SQL的 GRANT 命令
root@host# mysql -u root -p
Enter password:***
mysql> use mysql;
Database changed
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
-> ON TUTORIALS.*
-> TO ‘dc3688‘@‘localhost‘
-> IDENTIFIED BY ‘123456‘;
以上两种方式都可以为分别创建用户