I’m trying to install and setup MySQL on my Machine (MacBook Pro M3 Max with Sonoma 14.5 OS) but it is not being possible to login anymore. The root password keep being changed after I shut down the machine and turn it on on the next day.
When I run the the mysql_secure_installation
command and try to setup a password, the following access denied error happens:
$ mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
Error: Access denied for user 'root'@'localhost' (using password: YES)
I’ve tried to change the password for the root user by executing
sudo mysqld_safe --skip-grant-tables
, then
mysql -root
, then the commands to reset the password, but it says that a mysqld
process already exists, which blocks the execution of further commands.
$ sudo mysqld_safe --skip-grant-tables
2024年07月04日T17:57:49.6NZ mysqld_safe Logging to '/opt/homebrew/var/mysql/Victors-MacBook-Pro.local.err'.
2024年07月04日T17:57:49.6NZ mysqld_safe A mysqld process already exists
↳ This error is happening even after I kill all the mysqld
and mysql
processes with
sudo kill -9
or
sudo pkill -9 mysqld
or
sudo killall -9 mysqld
or
sudo killall -9 mysqld_safe
or listing all the processes with
ps aux | grep mysql
and killing each one of them manually via
sudo kill -9 <process_id>
So, in the end, I can’t use MySQL at all on my machine due to this login issue. Could someone help me? Thank you!
1 Answer 1
Just to let everyone know, here is the solution to this issue that can happen in MacOS Sonoma 14.5.
Remove the mysql
rm -rf /opt/homebrew/var/mysql
Install MariaDB
mariadb-install-db --user=$(whoami) --basedir="$(brew --prefix mariadb)" --datadir=/opt/homebrew/var/mysql
Login as root
sudo mysql -uroot
Change root password
set password = password("password");
exit
Now you can connect with MariaDB by mariadb -u root -ppassword
anytime you want
mariadb
com solved it tinyurl.com/bd95uj83. I would like to congratulate the support of themariadb
community. If someone if facing the same issue as me, please check this link.