Getting
Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
So I'm trying to install Mysql through homebrew, using the standard procedure: brew install mysql
But running Mysql gets this well-known error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (38)
I'm trying this on a fresh new computer. There isn't a /etc/my.cnf, but editing the socket locations does seem to affect the above error message (but doesn't fix the problem).
Any other basic steps I missed here?
Answer by Eric Dennis for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
Is mysql starting properly when you run /usr/local/bin/safe_mysqld
?
If so:
Verify the /tmp/mysql.sock
file exists.
If not do:
mysqld stop touch /tmp/mysql.sock // With old brew recipes safe_mysqld restart // With new brew recipes mysqld_safe restart
If mysql does not start properly after that last line:
You may need to install the tables manually using /usr/local/bin/mysql_install_db
, then restart mysql
.
Answer by Andrejas for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
First off, your mysql server isn't running. You can try to start it using
mysql.server start
If that fails, you can check the error log in /usr/local/mysql/data/[HOSTNAME].err. This file will give you clues. If you read something like
110717 11:41:43 InnoDB: Operating system error number 13 in a file operation. InnoDB: The error means mysqld does not have the access rights to InnoDB: the directory. InnoDB: File name ./ibdata1 InnoDB: File operation call: 'create'. InnoDB: Cannot continue operation.
.. you should make sure that your permissions are correct. For me, this solved it:
chown -R mysql:mysql /usr/local/mysql/data
If you still can't start it after that, google the error message at the bottom of /usr/local/mysql/data/[HOSTNAME].err
Answer by c.apolzon for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
If this is after a fresh install, its usually due to a lack of the necessary mysql system tables.
Solve with:
mysql_install_db
Then start the server with:
mysql.server start
or
~/Library/LaunchAgents/com.mysql.mysqld.plist
Answer by Anshuman Bhartiya for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
just follow the instructions from homebrew.
You can either start the server manually and stop manually by mysql.server start and mysql.server stop respectively.
or else, you can use launchctl to launch it everytime you start the shell.
You are getting the above error because you dont have mysqld running.
Do ps -ef | grep mysqld and you shouldn't see the mysqld daemon running.
You dont have to touch any /tmp/mysql.sock file.
Answer by Bardia for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
This fixed it for me.
If you tail /var/log/mysql/error.log you'll see the following being logged "...Cannot assign requested addresss..."
In /etc/mysql/my.cnf,then make sure the correct IP address is being assigned to it.
Answer by Moxley Stratton for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
This is what I did to get a socket created. Without these steps, there is no socket, and so you must connect to mysql using the host parameter (-h127.0.0.1).
Set up databases to run AS YOUR USER ACCOUNT with:
/usr/local/bin/mysql.server stop unset TMPDIR mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
Create a my.cnf file, /usr/local/etc/my.cnf:
[mysqld] socket=/tmp/mysql.sock
I recommend using lunchy to mange your mysql process, because launchctl is a pain to use. If you have Ruby with Ruby gems installed:
gem install lunchy lunchy start mysql
Answer by ksingh for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
- Go to "System Preferences".
- Click on the MySQL button in the "Other" pane.
- Click on "Start MySQL Server" button to start the server.
The server was stopped and this is why I was getting the error all this time.
Answer by yellowaj for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
I had the exact same problem installing through homebrew
. MySQL would not start and received the same error message.
After some time perusing google and SO I came across this post that solved my problem. Look here
I guess I neglected to follow the homebrew
instructions after installing it - who would have thought!
Hope this helps someone save an hour of their day.
Answer by New Alexandria for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
If you used launchctl
to control mysql
then you will need to use the same to load & unload it. I had the same problem as OP - it's not clear what caused it, but stopping and restarting mysql solved the issue.
stop it:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
start it:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
If stopping it fails, get the process id (ps aux | grep mysql
) and then kill -9
it.
Answer by David Kaltschmidt for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
I recently hit that error when upgrading mysql from 5.5.x to 5.6.x. In that case the grant tables need to be updated as outlined in Upgrading.
If the 5.6.x is already installed, you need to run mysql_upgrade
while having mysqld
running:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist /usr/local/bin/mysqld --skip-grant-tables
Then open a second shell and run
mysql_upgrade
In the first shell it will tell you what it repaired/updated. Then stop the mysqld
and start it properly via LaunchAgents:
killall mysqld launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Answer by Naoise Golden for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
I just wanted to mention that for Mac OS X users, you can go to System Preferences > MySQL (if installed) and make sure it is running.
Answer by petwho for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
Following Eric Dennis instruction, I couldn't get any success and my terminal window kept throwing the same error.
For those of you who is also in the situation like me try my simple solution:
cd /usr/local/mysql/data/bin
Change this location depends on your OS and installation
Then, run this command:
./mysqld_safe --no-defaults
You may need root permission for the above command.
Hope it will work for you.
Answer by Will for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
This fixed the problem for me. Use the activity monitor to look for mysqld instances and delete them all. Restart MySQL and it should be good to go.
Answer by Newb for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
The quickest check is to launch mysql on the db server with the -h set to 127.0.0.1 if it works then you need to config your system to see the local host.
Answer by Reg for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
I have tried a number the option above, without any success.
I install mysql with the help of brew, but when I tried to start up the sql server (mysql.server start) I got the following
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) In the end I had to delete the .err files located in /usr/local/var/mysql
Then, I tried reinstalling, creating the my.conf file, installing without brew... but still the same error**!
Then finally I deleted the .err files located in /usr/local/var/mysql (Got the idea from this guy http://goo.gl/VsPtP4)
Resulting in -
Starting MySQL . SUCCESS!
**See http://goo.gl/sYtMPW
Answer by ??? for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
I fixed the problem from this tutorial:
http://blog.joefallon.net/2013/10/install-mysql-on-mac-osx-using-homebrew/
Answer by krobs for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
Like mentioned, you have to run
mysql_install_db
which for me was producing FATAL ERROR: Could not find ./bin/my_print_defaults
.
Annoyingly, this just means you have to be in the right directory to execute this. Make sure you're in /usr/local/Cellar/mysql/
before running the script.
Answer by Subspacian for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
System Preferences -> MySQL Check status if its running...
Answer by Murali Panidepu for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
./mysql --socket=/home/test/database/MySQL_Database/data/axwayDB.socket -u root ?p
Use the command with the path to socket, it is under data folder. and this works to me
Answer by Brad Parks for Getting "Can't connect...through socket '/tmp/mysql'" when installing MySQL on Mac OS X 10.6 with Homebrew
For me on a mac, I needed to connect to use 127.0.0.1
instead of localhost
when trying to connect, as it seems one uses TCP/IP to connect, and the other is a socket connection. More info here
so the following worked:
mysql --host=127.0.0.1 -uroot -p
while this fails:
mysql --host=localhost -uroot -p
happy marriage anniversary uncle and aunty
ReplyDeleteanniversary wishes for chachu and chachi