mysql或者mariadb修改密码不生效

/etc/init.d/mysql stop
 vim /etc/my.cnf
添加
skip-grant-tables
mysql -u root
use mysql;
update user set password=PASSWORD("mynewpassword") where User='root';
update user set plugin="mysql_native_password";

flush privileges;

或者


/etc/init.d/mysql stop vim /etc/my.cnf添加 skip-grant-tables mysql -u rootuse mysql;update user set password=PASSWORD("mynewpassword") where User='root';update user set plugin="mysql_native_password";flush privileges;或者 1.systemctl stop mariadb ==>停止mariadb数据库 2.mysqld_safe --skip-grant-tables & ==>进入单机模式 3.mysql -uroot =>进入mariadb 4.use mysql;==>进入mysql库 5.update user set password=password(新密码) where user='root';==>设置新密码 6.flush privileges;==>刷新 7.新开窗口 mysqladmin -uroot -p shutdown ==>新密码测试关掉数据库,成功关闭就证明修改成功,此步骤也可能失败 失败处理方式 1)ps -e|grep mysqld 进行查找mysqld进程 2)kill掉进程 8.systemctl restart mariadb ==>重启服务

 

posted @ 2024-08-15 14:21  wuchangsoft  阅读(30)  评论(0编辑  收藏  举报