mariadb忘记root暗码
假如您忘记了MariaDB的root暗码,可以按照以下步骤来重置暗码:
停止MariaDB服务:
- sudo systemctl stop mariadb
复制代码 启动无权限表的MariaDB服务:
- sudo mysqld_safe --skip-grant-tables &
复制代码 登录到MariaDB:
在MariaDB命令行中,用以下命令革新权限表:
设置新的root暗码:
- SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');
复制代码 大概对于MariaDB 10.4及以上版本,利用:
- ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
复制代码 退出MariaDB命令行:
EXIT;
关闭无权限表的MariaDB服务:
- [root@centos7 ~]# ss -lntup | grep 3306
- tcp LISTEN 0 50 *:3306 *:* users:(("mysqld",pid=1647,fd=14))
- [root@centos7 ~]# kill -TERM 1647
- [root@centos7 ~]# mysql -uroot -pnew_password
- Welcome to the MariaDB monitor. Commands end with ; or \g.
- Your MariaDB connection id is 2
- Server version: 5.5.56-MariaDB MariaDB Server
- Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- MariaDB [(none)]>
复制代码 重新启动MariaDB服务:
- sudo systemctl start mariadb
复制代码 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |