ubuntu 18.04 安装的mysql 使用自动生产的密码
sudo cat /var/log/mysql/error.log |grep password
显示password
使用mysql -u debian-sys-maint -p登录
密码就是上面显示的密码
有些安装 mysql5.7安装完成后普通用户不能进mysql,原因:root的plugin被修改成了auth_socket,用密码登陆的plugin应该是mysql_native_password
然后运行以下命令
USE mysql;
切换数据库
UPDATE user SET plugin='mysql_native_password' WHERE User='root';
更改认证方式
update mysql.user set authentication_string=password('123456') where user='root' and Host = 'localhost';
或者
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
修改密码
flush privileges;
刷新权限
exit
然后重新登陆即可
如果提示 “[Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.” 则为空密码。
输入 sudo cat /etc/mysql/debian.cnf
显示
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = ndUmfWzlZffKdS5sqd
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = ndUmfWzlZKdS5sqd
socket = /var/run/mysqld/mysqld.sock
然后类似上面的操作
阅读(1329) | 评论(0) | 转发(0) |