Ubuntu查看数据库默认密码,并修改数据库密码

默认密码存放位置

sudo cat /etc/mysql/debian.cnf

使用user和password登陆后输入

show databases;
use mysql;

查看数据库版本:

SELECT VERSION();
对于新版的MySQL(MySQL 5.7.6 及以上版本),您可以使用以下语法来更新用户的密码:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root123456'; 

其余可尝试:

update user set authentication_string=PASSWORD("root123456") where user='root';
quit;

posted @ 2023-07-25 17:02  Bin_Go  阅读(469)  评论(0编辑  收藏  举报