欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Mysql 5.6添加修改用户名和密码的方法

程序员文章站 2024-02-04 20:38:40
先登录mysql shell> mysql --user=root mysql 有密码的需要添加 –password 或-p 选项 添加用户...

先登录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,insert,update,delete,create,drop on expenses.* to 'custom'@'host47.example.com';
mysql>create user 'custom'@'%.example.com' identified by 'obscure';
mysql>grant select,insert,update,delete,create,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');

以上所述是小编给大家介绍的mysql 5.6添加修改用户名和密码的方法,希望对大家有所帮助