CenterOS 8上修改msql的root密码和新增非root用户步骤

步骤一:

登录mysql,输入mysql -uroot -p并回车,此时登录成功。

步骤二:

检查mysql表是否可以看见,输入show databases;并回车。

步骤三:

查看root用户和其他用户之前的密码:

select host, user, password from mysql.user;
步骤四:

修改root用户密码:

Grant all privileges on *.* to 'root’@‘*' identified by '123456!' with grant option;
Grant all privileges on *.* to 'root’@'localhost' identified by '123456!' with grant option;
Grant all privileges on *.* to 'root’@‘127.0.0.1' identified by '123456!' with grant option;
步骤五:

新增michal并设置dink库的密码:

Grant all privileges on *dink* to ‘michal’@‘*' identified by '123456!' with grant option;
Grant all privileges on *dink* to ‘michal’@'localhost' identified by '123456!' with grant option;
Grant all privileges on *dink* to ‘michal’@‘127.0.0.1' identified by '123456!' with grant option;
步骤六:

执行刷新操作:

flush privileges; 
步骤七:

查看root用户和其他用户之前的密码是否已经修改

select host, user, password from mysql.user;
步骤八:

退出命令行

quit
步骤十三:

重启mysql服务:

service mysqld restart
步骤十四:

执行命令,输入密码看是否能正常访问

mysql -uroot -p
mysql -umichal -p
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容