Have you forgotten your Mac OS X 'ROOT' password and need to reset it? Follow these 4 simple steps:
1. Stop the mysqld server.
Typically this can be done by from 'System Prefrences' > MySQL > 'Stop MySQL Server'
or
On macOS Sierra & OS to start/stop/restart MySQL post 5.7 from the command line:
sudo launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
On OS X to start/stop/restart MySQL pre 5.7 from the command line:
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 restart
2. Start the server in safe mode with privilege bypass
From a terminal:
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
3. In a new terminal window:
For MySQL older than MySQL 5.7 use:
UPDATE mysql.user SET Password=PASSWORD('your-password') WHERE User='root';
For MySQL 5.7+ use:
USE mysql;
UPDATE mysql.user SET authentication_string=PASSWORD("your-password") WHERE User='root';
Refresh and quit:
FLUSH PRIVILEGES;
\q
4. Stop the mysqld server again and restart it in normal mode.
0 Комментарии