Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4142529
  • 博文数量: 447
  • 博客积分: 1241
  • 博客等级: 中尉
  • 技术积分: 5786
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-27 06:48
个人简介

读好书,交益友

文章分类

全部博文(447)

文章存档

2023年(6)

2022年(29)

2021年(49)

2020年(16)

2019年(15)

2018年(23)

2017年(67)

2016年(42)

2015年(51)

2014年(57)

2013年(52)

2012年(35)

2011年(5)

分类: Mysql/postgreSQL

2021-07-28 11:12:29

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

然后类似上面的操作



阅读(1268) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~