- 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, rest the authentication for root user.
For MySQL 8+ use:
mysql -u root
UPDATE mysql.user SET authentication_string=null WHERE User='root';
FLUSH PRIVILEGES;
exit;
- Set the new password for the root user.
mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpasswd';
- More info: http://stackoverflow.com/questions/6474775/setting-the-mysql-root-user-password-on-os-x