0
点赞
收藏
分享

微信扫一扫

mysql 5.7忘记密码


以上的修改密码改为了命令:

UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword') WHERE User = 'root' AND Host = 'localhost';

否则会报错;

————————————————

方法二:

该方法先修改mysql配置文件使其可以无密码登录,让后修改密码,之后便复原配置文件

修改/etc/my.cnf

vim /etc/my.cnf

配置文件添加skip-grant-tables

[root@VM_0_8_centos ~]# vim /etc/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables                       此处!!!!!!
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

保存后重启mysql

systemctl restart mysql

即可免密登录,命令行输入mysql直接登录

选择mysql数据库,输入下列命令重置密码,'new-password'即为所设置密码

USE mysql;

 

举报

相关推荐

mysql忘记密码

mysql忘记了密码

mysql忘记密码破解

mysql忘记密码(linux)

Linux忘记MySQL密码

linux下mysql 忘记密码

mysql 8.0 忘记root密码

mysql密码忘记如何操作

0 条评论