- Go to: 'System Preferences' >> 'MySQL' and stop MySQL
OR,
- sudo /usr/local/mysql/support-files/mysql.server start
- sudo /usr/local/mysql/support-files/mysql.server stop
- sudo /usr/local/mysql/support-files/mysql.server status
-
Make sure you have Stopped MySQL first (above).
-
Run the server in safe mode with privilege bypass:
sudo mysqld_safe --skip-grant-tables
-
In a new window connect to the database, set a new password and flush the permissions & quit:
mysql -u root
-
For MySQL older than MySQL 5.7 use:
UPDATE mysql.user SET Password=PASSWORD('rootpass') WHERE User='root';
For MySQL 5.7+ use:
UPDATE mysql.user SET authentication_string=PASSWORD("rootpass") WHERE User='root';
-
Now flush privileges:
FLUSH PRIVILEGES;
-
Restart MySQL server.
-
More info: http://stackoverflow.com/questions/6474775/setting-the-mysql-root-user-password-on-os-x
I’m having the same issue and the solution proposed didn’t work.
I’ve tried to change the password for the root user by executing
sudo mysqld_safe --skip-grant-tables
, thenmysql -root
, then the commands to reset the password, but it says that amysqld
process already exists, which blocks the execution of further commands.↳ This error is happening even after I kill all of the
mysqld
/mysql
processes withsudo kill -9
orsudo pkill -9 mysqld
orsudo killall -9 mysqld
orsudo killall -9 mysqld_safe
or listing all the processes withps aux | grep mysql
and killing each one of them manually viasudo kill -9 <process_id>
.I also tried to uninstall
mysql
, but when I run the themysql_secure_installation
command and try to setup a password, the following access denied error happens: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!