Introduction
Working with MySQL on macOS can sometimes lead to unexpected issues, whether you're setting up a new database or maintaining an existing one. In this post, we'll discuss how to address two common MySQL problems on macOS, particularly for those using Homebrew: changing the password policy and troubleshooting service start-up issues.
Adjusting MySQL Password Policy
The Issue
You might encounter an error (ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
) when trying to set a new MySQL password that doesn't include uppercase letters.
The Solution
-
Log in to MySQL
mysql -u root -p
-
Check Current Password Policy
SHOW VARIABLES LIKE 'validate_password%';
-
Adjust Policy
-
Lower the password policy level:
SET GLOBAL validate_password.policy = LOW;
-
- Change the password length requirement, if necessary:
```sql
SET GLOBAL validate_password.length = 8;
```
-
Set New Password
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password'; FLUSH PRIVILEGES;
-
Restart MySQL
brew services restart mysql
Troubleshooting MySQL Start-Up Issues
The Issue
Sometimes, after running brew services restart mysql
, MySQL is Loaded
but not Running
.
The Solution
-
Check MySQL Logs
-
Locate and view the error log:
cat /usr/local/var/mysql/hostname.err
-
-
Check MySQL Status
brew services list
-
Start MySQL Manually
-
This can give more immediate feedback:
mysql.server start
-
-
Check for Port Conflicts
lsof -i :3306
-
Check File Permissions
sudo chown -R $(whoami) /usr/local/var/mysql/
-
Repair MySQL Installation
-
Reinstall MySQL if necessary:
brew uninstall mysql brew install mysql
-
Conclusion
Dealing with MySQL on macOS can present challenges, but with the right approach, these can be easily overcome. Whether adjusting the password policy or troubleshooting service start-up, understanding how to navigate these issues is crucial for any developer.
Top comments (0)