Note: It HAS to be closed before this will work!
First, go to System Preferences
, go to MySQL
, and Stop MySQL Server
.
$ launchctl unload /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
$ killall mysql mysqld _mysql
$ ps aux | grep mysql
If you see mysqld
or _mysql
somewhere, take the number next to it, that is the process id. Now kill the process:
$ sudo kill -9 <PID>
# example: sudo kill -9 1234
# Kill the process with the same user that started it, above we used sudo for root
If you cant close mysqld
, you would need to restart your system and then restart Step 1.
$ sudo mysqld_safe --skip-grant-tables
If you see Starting mysqld daemon with databases from..
then it succeeded!
Open a new Terminal window while this window is running, do not stop this process or close window!
$ mysql -u root
Select mysql
database:
mysql> USE mysql;
Reset Password
:
mysql> UPDATE user SET Password=PASSWORD("NEW_PASSWORD") WHERE User='root';
mysql> FLUSH PRIVILEGES;
If that didnt work, try resetting authentication_string
:
mysql> UPDATE user SET authentication_string=PASSWORD("NEW_PASSWORD") WHERE User='root';
mysql> FLUSH PRIVILEGES;
Exit when done!
mysql> exit;
You can now close your first Terminal window to close the mysqld_safe
process.
Go to System Preferences
and start your MySQL Server
.
You can now log in with your new credentials:
$ mysql -u root -p
# enter new password
If this didn't work, continue with steps.
Go root
with:
$ sudo su
# enter your system password
Delete MySQL:
$ rm -rf /usr/local/mysql*
$ rm -rf /Library/StartupItems/MySQL*
$ rm -rf /Library/PreferencePanes/MySQL*
$ rm -rf ~/Library/PreferencePanes/MySQL*
$ rm -rf /Library/Receipts/mysql*
$ rm -rf /Library/Receipts/MySQL*
$ rm -rf /private/var/db/receipts/*mysql*
Restart your system to be safe!
NOTE: COPY THE PASSWORD AND KEEP IT IN TEXT FILE AND KEEP IT OPEN
$ mysql -u root -p
# enter given password
If that failed, try changing it with:
$ /usr/local/mysql/bin/mysqladmin -u root -p'TEMP_PASSWORD' password 'NEW_PASSWORD'
If that failed, go back to Step 1.