Linux (Debian) 安装MySQL 后如何获取登录密码

树莓派安装MySQL后获取登录密码

树莓派基于Debian系统。

成功安装MySQL后

su root
vim /etc/mysql/debian.cnf

其中 user 和 password 就是你用于登录mysql的默认账户和密码。

mysql -udebian-sys-maint -p
//键入passwd

就可以成功进入MySQL服务界面,更新默认账户密码设置。

show databases; // 1.展示所有数据库
use mysql; //2.选择mysql数据库
// 3.更新root密码(5.7 之前的mysql)
update mysql.user set password=password('123456') where user='newuser' and host='localhost';
//3.更新root密码(5.7 之后的mysql) 这两个命令可以都尝试下
update mysql.user set authentication_string=password('123456') where user='newuser' and host='localhost';
//4.权限刷新
flush privileges;

之后就可以用我们最熟悉的mysql-uroot -p来登录了。

posted @ 2020-05-04 19:07  Kindear  阅读(1153)  评论(0编辑  收藏  举报