Mysql 5.6 添加、修改用户名和密码的简单示例

前端之家收集整理的这篇文章主要介绍了Mysql 5.6 添加、修改用户名和密码的简单示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!

登录MysqL

shell> MysqL --user=root MysqL

有密码的需要添加 –password 或-p 选项

添加用户

MysqL>CREATE USER 'finley'@'localhost' IDENTIFIED BY 'some_pass';
MysqL>GRANT ALL PRIVILEGES ON *.* TO 'finley'@'localhost' WITH GRANT OPTION;
MysqL>CREATE USER 'finley'@'%' IDENTIFIED BY 'some_pass';
MysqL>GRANT ALL PRIVILEGES ON *.* TO 'finley'@'%' WITH GRANT OPTION;
MysqL>CREATE USER 'admin'@'localhost' IDENTIFIED BY 'admin_pass';
MysqL>GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';
MysqL>CREATE USER 'dummy'@'localhost';

添加用户并设置数据库具体权限:

MysqL>CREATE USER 'custom'@'localhost' IDENTIFIED BY 'obscure';
MysqL>GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON bankaccount.* TO 'custom'@'localhost';
MysqL>CREATE USER'custom'@'host47.example.com' IDENTIFIED BY 'obscure';
MysqL>GRANT SELECT,DROP ON expenses.* TO 'custom'@'host47.example.com';
MysqL>CREATE USER 'custom'@'%.example.com' IDENTIFIED BY 'obscure';
MysqL>GRANT SELECT,DROP ON customer.* TO 'custom'@'%.example.com';

删除用户

MysqL>DROP USER 'jeffrey'@'localhost';

修改密码

MysqL>SET PASSWORD FOR 'jeffrey'@'localhost' = PASSWORD('mypass');

修改当前登录用户密码:

MysqL>SET PASSWORD = PASSWORD('mypass');
原文链接:https://www.f2er.com/mysql/530253.html

猜你在找的MySQL相关文章