mariadb忘记root暗码

[复制链接]
发表于 2024-11-27 06:30:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
mariadb忘记root暗码
假如您忘记了MariaDB的root暗码,可以按照以下步骤来重置暗码:
停止MariaDB服务:
  1. sudo systemctl stop mariadb
复制代码
启动无权限表的MariaDB服务:
  1. sudo mysqld_safe --skip-grant-tables &
复制代码
登录到MariaDB:
  1. mysql -u root
复制代码
在MariaDB命令行中,用以下命令革新权限表:
  1. FLUSH PRIVILEGES;
复制代码
设置新的root暗码:
  1. SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');
复制代码
大概对于MariaDB 10.4及以上版本,利用:
  1. ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
复制代码
退出MariaDB命令行:
EXIT;
关闭无权限表的MariaDB服务:
  1. [root@centos7 ~]# ss -lntup | grep 3306
  2. tcp    LISTEN     0      50        *:3306                  *:*                   users:(("mysqld",pid=1647,fd=14))
  3. [root@centos7 ~]# kill -TERM 1647
  4. [root@centos7 ~]# mysql -uroot -pnew_password
  5. Welcome to the MariaDB monitor.  Commands end with ; or \g.
  6. Your MariaDB connection id is 2
  7. Server version: 5.5.56-MariaDB MariaDB Server
  8. Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
  9. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  10. MariaDB [(none)]>
复制代码
重新启动MariaDB服务:
  1. sudo systemctl start mariadb
复制代码
回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表