This article brings you relevant knowledge about mysql, which mainly introduces related content about user management, including creating new users, viewing user information, renaming users, deleting users, etc. Let’s take a look at the content below, I hope it will be helpful to everyone.
Recommended learning: mysql video tutorial
create user '用户名'@'主机名' [identified by [password] '密码'];
If we want an ordinary user to view this mysql library, we need to use grant for authorization. Note that authorization work can only be performed by the root user.
Remote login, that is, remote login to the local database from other hosts
View the mysql.user table
rename user '旧用户名'@'旧主机名' to '新用户名'@'新主机名';
drop user '用户名'@'主机名';
set password = password('新密码')
2. Change the password of other users
set password for '用户名'@'主机名' = password('新密码');普通用户是无法修改其他用户密码的
##1.6 What to do if you forget your password
vim /etc/my.cnf #修改mysql配置文件 [mysqld] ...... skip-grant-tables #在mysqld模块下添加该配置 wq保存退出 systemctl restart mysqld #重启mysql服务 mysql #mysql直接登录 update mysql.user set authentication_string = password('新密码') where User='root'; flush privileges; 退出重新登陆 切记:修改完后一定将配置文件的skip-grant-tables注释或者删掉,不然再执行一次重启数据库,还是可以无密码登录,很危险
grant,授权,通常用于root用户授予普通用户一些执行权限,比如select,insert,update。
grant 权限列表(select|insert|delete|drop|update等等)on 数据库名.表名(*表示所有) to '用户名'@'主机名' [identified by '密码']; 若授权的用户不存在,mysql会先创建一个用户,然后进行授权操作
show grants for '用户名'@'主机名'; #查看指定用户的权限show grants; #查看当前用户权限
revoke 权限列表 on 库名.表名 from '用户名'@'主机名'; #从用户XXX撤销XX库.XX表的XX操作的权限
推荐学习:mysql视频教程
The above is the detailed content of Graphical examples analyzing MySQL user management. For more information, please follow other related articles on the PHP Chinese website!