系统:centos 7.2
mysql版本:mysql 5.7
平台:腾讯云
安装MySQL时,没有让我输入密码,所以安装完后,需要自己找。
密码在mysqld.log 文件中
输入命令find / -name mysqld.log
查找其位置
在xshell 6中,ctrl+shift+F可以查找字段password
使用cat命令查看文件
查找到默认密码之后,就可以用
mysql -u root -p
进入mysql,然后输入密码
修改密码:
使用命令
update mysql.user set authentication_string=password('*******') where user='root';
参考 https://www.cnblogs.com/wangbaobao/p/7087032.html
很多教程里提到的
update user set password=password(“新密码”) where user=”用户名”;
在当前mysql版本会出错。