centos 中修改root用户名和修改mysql中root用户名的方法

centos中修改root用户名的方法:

1.在 /etc/passwd 中把root 替换成你要修改成的用户名,然后保存退出;

2.在/etc/shadow中把root替换成你要修改成的用户名,然后保存退出;
修改MYSQL用户名的方法:

MySQL 5.7 之后password字段已从mysql.user表中删除了,新的字段名是“authenticalion_string”

use mysql;
所以修改mysql中用户名的方法如下:
update user set authentication_string=password(“Asat123@”) where user=“cdzx” and Host=“localhost”;
刷新命令:flush privileges;

修改root用户名的方法
update user set user=“newName” where user=“root”;

flush privileges;

最后修改登录时候显示自己用户名的方法:
在/etc/profile 文件中添加以下内容:

显示用户信息的命令: export PS1=’[\u@\h\w]’

最后使用命令使起生效:source /etc/profile 命令。

猜你喜欢

转载自blog.csdn.net/weixin_44881103/article/details/103079232