I was running DatabaseCleaner tests on Rails and ended up breaking MySQL completely. I've completely removed and re-installed it and still can't get it to run. Used brew uninstall mysql and brew install mysql to start fresh, but it's broken even upon re-install.
❯ brew services start mysql
Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/allan/Library/LaunchAgents/homebrew.mxcl.mysql.plist` exited with 5.
❯ mysql.server start
Starting MySQL
./usr/local/Cellar/mysql/8.0.31/bin/mysqld_safe: line 144: /usr/local/var/mysql/Allans-MacBook-Pro.local.err: Permission denied
/usr/local/Cellar/mysql/8.0.31/bin/mysqld_safe: line 144: /usr/local/var/mysql/Allans-MacBook-Pro.local.err: Permission denied
/usr/local/Cellar/mysql/8.0.31/bin/mysqld_safe: line 199: /usr/local/var/mysql/Allans-MacBook-Pro.local.err: Permission denied
/usr/local/Cellar/mysql/8.0.31/bin/mysqld_safe: line 144: /usr/local/var/mysql/Allans-MacBook-Pro.local.err: Permission denied
ERROR! The server quit without updating PID file (/usr/local/var/mysql/Allans-MacBook-Pro.local.pid).
❯ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
HOWEVER if I run mysqld it actually runs and then I can access it! Does anyone know how to fix this without having to factory reset my Macbook? running Moneterey version 12.4
Related
I have been running all my apps with Rails and PostgreSQL, which was very easy to setup using brew install postgresql and brew services start postgresql. With MySQL is proving to be a very big pain.
How do I setup MySQL from 0 and clean up all the mess I made?
I have downloaded MySQL Community Server 8.0.21 on my MacOS and registered a root password during the setup.
After that I have run the folowing commands that render the following errors.
$ mysql -u root -p
# ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61)
$ mysql.server start
# Starting MySQL
# ./usr/local/Cellar/mysql/8.0.21_1/bin/mysqld_safe: line 144: /usr/local/var/mysql/Victors-MBP.err: Permission denied
# /usr/local/Cellar/mysql/8.0.21_1/bin/mysqld_safe: line 144: /usr/local/var/mysql/Victors-MBP.err: Permission denied
# /usr/local/Cellar/mysql/8.0.21_1/bin/mysqld_safe: line 199: /usr/local/var/mysql/Victors-MBP.err: Permission denied
# /usr/local/Cellar/mysql/8.0.21_1/bin/mysqld_safe: line 144: /usr/local/var/mysql/Victors-MBP.err: Permission denied
# ERROR! The server quit without updating PID file (/var/run/mysql/mysqld.pid).
$ brew doctor
$ brew uninstall mysql
$ brew cleanup
$ brew install mysql
# The whole setup works, but every attempt to run the server still renders the same errors.
$ mysql_secure_installation
# after inputting the correct root password...
# Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61)
Please help. I have tried many more different setups and corrections, none of which have worked.
Thank you in advance!
MySQL has a simple Macintosh installer and a control-panel that goes along with it ... shows up in "System Preferences." Are you sure that the server is actually running? Betcha it ain't.
This worked: https://superuser.com/a/603027/1220403
Basically execute this command:
$ mysql -u root mysql
And you'll be able to set a password using ALTER USER and access the mysql command line. Also, you'll be able to start the server.
When trying to start mysql, I receive the following error message:
ERROR 3118 (HY000): Access denied for user 'root'#'localhost'. Account is locked.
I've installed MySQL via homebrew on my OSX and have not encountered such an issue until yesterday. When I try to run mysqld_safe, I receive:
mysqld_safe mysqld from pid file /usr/local/var/mysql/****.pid ended.
If I try sudo mysqld stop, I receive:
Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
I am unable to sudo restart mysql.server as I receive:
ERROR! MySQL server PID file could not be found!
I looked into running a data dump of my db but I am prevented from doing this as well.
Thanks for your attention to this matter and any insight you can provide in this matter. I greatly appreciate it.
Here is my problem: I cannot login to MySQL since I forgot the temporary password, i.e., the one that was assigned to me when I installed MySQL (if I type mysql in the command line, I receive this error: ERROR 1045 (28000): Access denied for user 'mona'#'localhost' (using password: NO). I receive the same error when I try with mysql -u root), so I tried the following to fix it:
I turned off MySQL
Then I created a file called restore in which I wrote SET PASSWORD FOR root#localhost=PASSWORD('');
Finally, sudo mysqld_safe --init-file=/usr/local/mysql/support-files/restore which didn't work. Then I tried step 3 with this command sudo /usr/local/mysql/support-files/mysql.server start and I got this error ERROR! The server quit without updating PID file (/var/run/mysqld/mysqld.pid).
In order to fix the last error, I tried the followings:
ps aux | grep mysql and killed MySQL processes. Then I started MySQL server but I received the same error again.
I checked my.cnf file in /private/etc (everything was commented in this file except this line: pid-file = /var/run/mysqld/mysqld.pid, but I found there is no mysqld folder in /var/run, instead it is located in this path: /usr/local/mysql-5.7.11-osx10.9-x86_64/bin/).
Now, I feel confused: why in /usr/local/, there are both mysql folder and mysql-5.7.11-osx10.9-x86_64?? what is their difference then? (I know the one I installed is the latter one)
How can I fix this issue?
I am attempting a fresh install of mysql on a new iMac running OSX 10.11. I downloaded the latest 10.10 dmg and followed installation directions, but when I try to run mysql, I get the
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).
I have spent several hours reading answers here and elsewhere as to how to fix it, and nothing has worked so far.
What I know:
The /tmp/mysql.sock file has been renamed /tmp/mysql.sock.lock. Apparently, if I could get mysqld to run, it would make a new socket file, but when I try to get mysqld to run (either from the Terminal or System Preferences) it just fails and produces the same error. Likewise, when I try to run mysqladmin it fails and produces the same error.
When I run mysqld_safe, it produces the following, but doesn’t clear up the socket error:
151206 16:40:20 mysqld_safe Logging to '/usr/local/mysql/data/XXXXXXs-iMac.err'.
151206 16:40:20 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
151206 16:42:01 mysqld_safe mysqld from pid file /usr/local/mysql/data/XXXXXXs-iMac.pid ended
When I ran mysql on Lion, I was always able to clear up socket errors by running mysqld_safe.
Advice?
Run the command 'sudo mysqld' from the command line to launch the server.
Getting this error when trying to run the command /usr/local/mysql/bin/mysqld_safe:
mysqld_safe Logging to '/usr/local/mysql/data/Users-MacBook-Pro.local.err'.
cat: /usr/local/mysql/data/Users-MacBook-Pro.local.pid: Permission denied
rm: cannot remove ‘/usr/local/mysql/data/Users-MacBook-Pro.local.pid’:
Permission denied
140313 11:09:18 mysqld_safe Fatal error: Can't remove the pid file:
/usr/local/mysql/data/Users-MacBook-Pro.local.pid
Please remove it manually and start /usr/local/mysql/bin/mysqld_safe again;
mysqld daemon not started
/usr/local/mysql/bin/mysqld_safe: line 129:
/usr/local/mysql/data/Users-MacBook- Pro.local.err: Permission denied
Shoould I remove the file? Is it safe to remove it?
Remove this pid file, make sure all the instances are stopped (kill any processes not going down), check nothing is listening the MySQL port 3306 (netstat should help) and try to start MySQL again.
To troubleshoot this see the permission you user has on the folder where the pid needs to be stored !
Try running the command with SUDO in front of it, like this
sudo /usr/local/mysql/bin/mysqld_safe
Enter your password. This will most likely resolve your problem.
The reason you are getting these errors is because the command you are running to start mysql requires access to certain files (listed in the error message). You need root access to these files to start mysql, so by adding sudo to the start of the command, you are giving root access.