Problems starting MySQL on Mac OS X - mysql

I am not able to start MySQL server on Mac OS X 10.4.11. MySQL was installed using Macports. MySQL was running fine until it suddenly died without any obvious reason.
When running "mysql", I get the error message:
ERROR 2002 (HY000): Can't connect to local MySQL server through
socket '/opt/local/var/run/mysql5/mysqld.sock' (2)
If I try to start MySQL manually, I get the following error message:
sudo /opt/local/share/mysql5/mysql/mysql.server start
Starting MySQL/opt/local/share/mysql5/mysql/mysql.server: line
159: kill: (636) - No such process
ERROR!
In /etc/mysql/my.cnf I have:
socket = __PREFIX/var/run/mysqld/mysqld.sock
But the path "opt/local/var/run/mysqld/" does not exist on my system.
I tried to change the socket path to "__PREFIX/var/run/mysql5/ mysqld.sock" (which is where the socket is located). Unfortunately, this did not help either.
Owner and Permissions for /opt/local/var/run/mysql5/ are correctly set.
Any suggestions on how to start MySQL again? Thanks for your advice.

I use a Mac too and install MySQL from macports. I have experienced the same WTF moments you describe, and I've had to resort to this solution to restart MySQL:
# launchctl unload /Library/LaunchDaemons/org.macports.mysql5.plist
# launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
That seems wrong, too brute force. But I haven't found a better solution yet. I suggest searching ServerFault.com and see if someone else has a better method. Please post here if you do find something.
#lacopo: Why use macports? Because macports is really picky about dependencies. If you use any macports tools that depend on MySQL, it's easier to install MySQL via macports.

Related

mysql server does not shutdown with the error : 'the server quit without updating pid file'

environment
OS X El Capitan 10.11 , Mysql 5.6.26
What I did
mysql port was 3307 when I installed it. ( I didn't install it using brew.)
I changed the port 3306 to 3306 by editing /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist after using mysql with 3307 port for 6 months well.
I revised <string>--port=3307</string> to 3306.
I tried to stop and It didn't work. So I used following:
sudo kill -9 [PID]
It's killed and didn't start. So I changed the port 3006 to 3007.
I tried to start mysql server with following command and got a error.
sudo /usr/local/mysql/support-files/mysql.server start
ERROR! The server quit without updating PID file (/var/lib/mysql/nhnui-MacBook-Pro.local.pid).
And I found some helpful advices in follwing link.
reference link :
After MySQL install via Brew, I get the error - The server quit without updating PID file
I tried to change ownership of files, checking my.cnf file, checking error log file and all didn't work for me.
Finally, I removed /usr/local/mysql/datamysqld.local.err , /usr/local/mysql/datamysqld.local.pid and rebooted mac.and I can start mysql server.
The Problem
Then, the problem is above tip is not perfect for me.
mysql server was running after restarting mac. I checked it with 'ps-ef | grep mysql'.
Stop and start was success and then it didn't stop it again cause of same error!
Screenshot of the error :
Of course, I did it again (I mean deleting .err , .pid file / rebooting mac / cheking mysql ps / stop - start (well) / stop (got error)) and checked that it has same error.
Here is the error log : /usr/local/mysql/data/mysqld.local.err
Now, mysql server can't stop.
What can I do to solve this?
P.S - If it will be better to reinstall mysql, I should do that.
Make a backup of your system.
Dump your data into text files.
Uninstall everything releated to mySql (a quick Google search will point you to several how-tos)
Reinstall mySql from the package in the .dmg available from mySql website.
You can choose the latest 5.6.x or 5.7.x
Set the mySql root password and you're done.
When things get messy and all you can do is guessing what's the fix it's faster to reinstall given that a package installer is provided for mySql (you don't have to compile it yourself or play with brew/macports).

Can't start MySQL server on osX 10.11 - can't find PID file error

Fisrt of all, you must know that I am a total newbie, non-coder, graphique designer that will be able to copy/paste any code but don't not assume that I can deduce any code/terminal command whatsoever please: I don't know the syntax.
So, here's my issue: I know there are plenty of issues on the web about this, even here, but all by myself I haven't been able to fix my poblem no matter how many thread I've read. I fear I'll need to be held by the hand through this.
I am trying to get a WordPress installation working locally on my Mac Book Pro running osX El Capitan 10.11. I tried following the instructions in that article: http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/ .
It worked well untill I hit the MySQL section. Since I thought there was an issue with my root password (it ended out that the MySQL install had provided me a temporary pass that I forgot about), I tried uninstalling my MySQL install following these instructions: https://php-built.com/uninstall-mysql-from-os-x-yosemite/ , but after re-installing MySQL I kept getting this error: .. ERROR! The server quit without updating PID file (/usr/local/mysql/data/wks-000353.pid).
So, in a nutshell,
This:
sudo /usr/local/mysql/support-files/mysql.server start
... renders this:
.. ERROR! The server quit without updating PID file (/usr/local/mysql/data/wks-000353.pid)
This:
/usr/local/mysql/bin/mysql -v
... renders this:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
And this:
sudo /usr/local/mysql/support-files/mysql.server restart
... renders this:
ERROR! MySQL server PID file could not be found!
Help would be highly appreciated!!

MySQL not working after Kubuntu upgrade

I have just upgraded to Kubuntu 15.04 and MySQL is no longer working properly. The error is:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2)
I have checked and there is no mysqld.sock file at that location (and no directory 'var/run/mysqld'). I've tried creating a directory at 'var/run/mysqld' and using chmod to make it writable by all, then restarting MySQL using 'sudo service mysql restart', but this doesn't solve the problem.
MySQL seems to be running (it's coming up as loaded & active when I run 'sudo service mysql status'). There's nothing in the MySQL error log.
I can't find any mysqld.sock file at all (did a search across the whole file system).
Any solutions before I give up and purge/reinstall mysql would be gratefully appreciated!
EDIT to add:
The MySQL process itself isn't in the process list. No errors are thrown when I start/restart MySQL using 'sudo service mysql', and /var/log/mysql/error.log is empty.
I managed to get it working by changing the permissions on /var/lib/mysql and then running "mysqld" at the command line
So presumably some sort of permissions screw-up that happened as part of the Kubuntu upgrade.

Homebrew "brew install mysql" giving "...Error while setting value '127.0.0.1' to 'server_id'"

I recently upgraded my system to OS X Yosemite and started encountering some issues to connect locally to my Database via MySQL Workbench.
It was mainly classic ones about the PID files and socket, that I managed to find solutions for looking over the web. However one was remaining : "Can't connect to MySQL server on '127.0.0.1' (61) (2003)", and none of the solutions I found on the MySQL website, stackoverflow and other forums were working.
I therefore decided to reinstall MySQL using the dmg file (version for OS X 10.9 though, no version yet available for 10.10). It did not work.
That's why I eventually uninstalled every little piece of mysql that I could and reinstalled a clean version using homebrew. The steps I followed are those ones.
However, this did not work either and here is the error message I got :
$ brew postinstall mysql
==> /usr/local/Cellar/mysql/5.6.21/bin/mysql_install_db --verbose --user=Antoine
Installing MySQL system tables...Unknown suffix '.' used for variable 'server_id' (value '127.0.0.1')
2014-10-20 02:35:05 0 [ERROR] /usr/local/Cellar/mysql/5.6.21/bin/mysqld: Error while setting value '127.0.0.1' to 'server_id'
2014-10-20 02:35:05 0 [ERROR] Aborting
2014-10-20 02:35:05 0 [Note] Binlog end
It makes now a little more sense that MySQL server was not able to connect to 127.0.0.1, but I must say that I'm lost and do not really know where to look anymore. I can't find anything on this error message. I had a look to the mysqld file, but it was useless.
Do you think the issue is linked to OS X Yosemite? Any clue of what I could do from here?
I had the same problem, here the solution:
http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/
You only have to start again MySql:
sudo /usr/local/mysql/support-files/mysql.server start
I eventually managed to fix the issue by, in this order :
1/ Upgrading to xcode command line tools 6.1
2/ Following those steps to remove completely MySQL
3/ Restarting my computer
4/ Installing MySQL back with the OS X 10.9 package (dmg file available on mysql website)
5/ Copying the my-default.cnf file to the etc folder : sudo cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
6/ Starting the server the first time with this command in terminal : sudo /usr/local/mysql/support-files/mysql.server start
No PID issue, no socket issue, no connection issue to localhost. Everything's fine now.

Doctrine 2 command line tool; MAMP and mysql.sock

I grabbed the CI2/Doctrine2 from Wildly Inaccurate. I'm trying to start using it, but before I'm actually getting to work with it, I wanted to make sure everything works. However, when I try the command line tool, I run into the following error:
$ ./doctrine orm:schema-tool:create
ATTENTION: This operation should not be executed in a production environment.
Creating database schema...
Warning: PDO::__construct(): [2002] Socket operation on non-socket (trying to connect via unix:///var/mysql/mysql.sock) in /Users/joris/Desktop/ci2_starter/application/libraries/Doctrine/DBAL/Driver/PDOConnection.php on line 36
[PDOException]
SQLSTATE[HY000] [2002] Socket operation on non-socket
orm:schema-tool:create [--dump-sql]
I'm running this on a cleanly installed MAMP Pro 2.0.1; I'm not really sure what to do to fix this error.. I'm not really knowledgeable on the inner (background) workings of MySQL. Could someone clear this up for me? Thanks a lot.
Update:
MacBook-Pro-van-Joris-Ooms:~ joris$ sudo find / -name 'mysql.sock'
Password:
/Applications/MAMP/tmp/mysql/mysql.sock
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/private/var/mysql/mysql.sock
/private/var/mysql/mysql.sock/mysql.sock
MAMP does use it's own mysql socket while the CLi uses the default one in /var/mysql/mysql.sock.
This could mean you are running the wrong PHP version (not the MAMP one but the default MAC OS X one). Not a big deal since it can deal with your Doctrine Command Line Issues as well.
So you do have several options:
try using the MAMP php version to start the CLi tool by putting the Path to your MAC OS X php version as a prefix i.e.
/Applications/MAMP/bin/php5.3/bin/php ./doctrine orm:schema-tool:create
just set up a link from /var/mysql/mysql.sock to the actual Socket file which should be in /Applications/MAMP//tmp/mysql/mysql.sock
So you go to the terminal while your MAMP is running an type (You will be asked to type in a password):
sudo ln -s /Applications/MAMP//tmp/mysql/mysql.sock /var/mysql/mysql.sock
Find every occurrence of "/Applications/MAMP//tmp/mysql/mysql.sock" in any of your MAMP config files and change it to be /var/mysql/mysql.sock so you actually do use the default address for MySQL Socket. Though, i have never tested if this does work.