在OSX上重置MySQL / MariaDB密码

时间:2019-03-25 23:50:44

标签: mysql mariadb homebrew

遵循this guide之后,我已经通过Homebrew安装了MariaDB。一切正常,但是今天root密码已经过期,我似乎无法使用任何—skip-grant-tables —skip-networking类型的选项来重置它。

到目前为止,我已经尝试过:

brew services stop mariadb
mysqld_safe --skip-grant-tables --skip-networking
mysql_secure_installation

也尝试过

mysql_secure_installation --connect-expired-password

哪个给我:

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
/usr/local/Cellar/mariadb/10.3.13_1/bin/mysql: unknown option '--connect-expired-password'
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: 
Re-enter new password: 
/usr/local/Cellar/mariadb/10.3.13_1/bin/mysql: unknown option '--connect-expired-password'
Password update failed!
Cleaning up...

我还添加了:

[mysqld]
default_password_lifetime=0
skip-grant-tables

/usr/local/etc/my.cnf

仍然不允许我使用上述命令更新root密码。 酿酒医生回来干净了,我快要尝试了。

2 个答案:

答案 0 :(得分:0)

最终运行/usr/local/mysql/bin/mysqladmin -u root -p password并设置新密码。

答案 1 :(得分:0)

登录

mysql -uroot

然后做

set password = password("your_password");