On Mac OS X v10.6 (Snow Leopard), starting MySQL gives the following error:
The server quit without updating PID file
[mysqld] port = 3306 socket = /tmp/mysql.sock skip-external-locking key_buffer_size = 16K pid-file=/var/run/mysqld/mysqld.pid [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
pid in the /usr/local/mysql/data/ directory.
normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server. You should also check that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.
You could try using "127.0. 0.1" if the socket connector is not enabled/working. In that case, you should probably check if your MYSQL server is actually running. You can also force using a socket with the socket parameter (-S with /usr/bin/mysql) and force TCP/IP by providing a port (-P with /usr/bin/mysql.)
Try to find your log file with suffix ".err". There should be more information. It might be in:
/usr/local/var/mysql/your_computer_name.local.err
It's probably a problem with permissions
Check if any MySQL instance is running
ps -ef | grep mysql
If yes, you should stop it, or kill the process:
kill -9 PID
where PID
is the number displayed next to the username on the output of the previous command
Check ownership of /usr/local/var/mysql/
ls -laF /usr/local/var/mysql/
If it is owner by root
, you should change it to mysql
or your_user
sudo chown -R mysql /usr/local/var/mysql/
Follow the instructions from brew install mysql
.
Set up databases to run as your user account with:
For MySQL 5.x:
unset TMPDIR mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
To set up base tables in another folder, or use a different user to run mysqld, view the help for mysqld_install_db
:
mysql_install_db --help
And view the MySQL documentation:
For MySQL 8.x:
unset TMPDIR mysqld --initialize-insecure --log-error-verbosity --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
Make sure the data directory /usr/local/var/mysql
above is empty. Back it up if necessary.
To run as, for instance, user "mysql", you may need to sudo
:
sudo mysql_install_db ...options...
Start mysqld manually with:
mysql.server start
Note: if this fails, you probably forgot to run the first two steps up above
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With