So I deleted all users in mysql.user and restarted mysql database. Now I can't seem to get into mysql again or how to reset it as if it was a fresh install. I tried uninstalling it using brew uninstall mariadb
and then reinstalling it using brew install mariadb
but that didn't fix the problem. The only resources I can find are on how to restore a user from within mysql (which I'm struggling to get into) or how to completely remove mysql by deleting files in certain directories (that don't exist in the first place). < /p>
P粉9860280392023-12-14 10:11:56
I finally found a solution to the problem. I didn't end up getting it from one source, but cobbled together a bunch of different things until I figured out that this worked.
mysql --skip-grant-tables
mysql_upgrade --force
ps -ef | grep mysql
followed by kill -9
brew services start mariadb
I did try mysql_install_db
first instead of mysql_upgrade --force
as some sites suggested, but that didn't work since the mysql.user
table still exists. It's just empty.
P粉6004020852023-12-14 09:05:11
There are two methods:
method one:
1. Uninstall the mysql database, delete the data files in the /data directory, and then reinstall
Method 2:
1. Stop the mysql service (systemctl stop mysqld)
2. Delete the files in the /data directory (rm -fr /data/*)
3. Initialize mysql (mysqld --defaults-file=/mysql/my.cnf --initialize --user=mysql --basedir=/mysql/app/mysql --datadir=/mysql/data/3306/data/)
PS1: The path may be different from yours and needs to be changed according to your own data directory