I am a bit new Mac. I tried installing mysql5 using the following link:
http://matthewcarriere.com/2008/04/02/installing-mysql-on-mac-os-x-leopard-using-macports/
When I tried running the following:
sudo /opt/local/bin/mysqld_safe5 &
I got this:
[2] 59079
ps: No user named 'axww'
130911 13:35:11 mysqld_safe Starting mysqld daemon with databases from /opt/local/var/db/mysql5
After this, I tried the following:
mysqladmin5 -u root -p ping
I got the following error:
mysqladmin5: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/opt/local/var/run/mysql5/mysqld.sock' exists!
How do I fix this?
That article is obviously a bit antiquated. The modern preferred way to start a daemon installed with MacPorts is by using the port load command.
sudo port load mysql5-server
Stop it by using port unload.
Related
Since I've updated my Mac to the lastest OS version (Ventura 13.2) and I'he made some cleanup (hopefully I didn't remove any important file). I can't connect to mySql
I've insatlled mysql with brew (long before this update) and it always has worked fine.
When I run brew services start mysql in my terminal it looks to work (Successfully started mysql (label: homebrew.mxcl.mysql))
But, as soon as I run mysql -u root -p and I enter my password I have the following error message ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
When I explore /tmp directory I see that /tmp/mysql.sock is a symlink to /var/lib/mysql/mysql.sock but mysql directory doesn't exist in /var/lib.
After extensive research I didn't find how to "get" this directory.
I've found many entries in StackOverflow with the same title, I've tried almost all answer but none seems to work. especialy in my case I'm using brew and macOS ventura.
Typicaly for ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' the accepted answer is not about brew.
I've tried brew reinstall mysql.
I've tried as well mysql -h 127.0.0.1 -u root -p in this case the error is ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1:3306' (61).
I've tried to run mysqld and then brew services start mysql, in this case I have the following error
Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/502 /Users/CedMacBook1/Library/LaunchAgents/homebrew.mxcl.mysql.plist` exited with 5.
I've tried to change my password using sudo mysqladmin -u root password -p and once again I have the error error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'.
It looks like mysql is runningm, I've ran ps aux | grep mysqld and get the following line:
CedMacBook 21853 0,0 0,0 34400496 2728 s000 S+ 7:53 0:00.01 grep mysqld
Finally I've checked my /usr/local/etc/my.cnf and I have the following
# Default Homebrew MySQL server config
[mysqld]
socket=/tmp/mysql.sock
# Only allow connections from localhost
bind-address = 127.0.0.1
port=3306
mysqlx-bind-address = 127.0.0.1
At this stage I'd be happy to swipe out everything... if I could save all my database
Please help, I don't know what else to try
Can someone help me? I've tried searching for a few ways to fix it, but no success!
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
To solve this issue you need to stop mysql process either through:
systemctl stop mysql
or
service mysql stop
after than you’ll need to expose the directory which has the socket configurations to the user who is running the process, this can happen through:
sudo usermod -d /var/lib/mysql/ mysql
then go back and start / restart mysql process again through:
systemctl start mysql
or
service start mysql
In my case not install mariadb server, You can try here
sudo apt install mariadb-server
If you have this error during the process to install mariadb (exemple) :
Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
You have to start mariadb in the first place :
systemctl start mariadb
Or if you are using WSL :
service start mariadb
I tried a lot to install MySQL8 via Homebrew on Mac 10.14.5. I was running MySQL 5.7 before that and did the following: I removed MySQL completely via this tutorial: https://coderwall.com/p/os6woq/uninstall-all-those-broken-versions-of-mysql-and-re-install-it-with-brew-on-mac-mavericks
After that I run mysql and got the message that the command was not known. So I installed mysql with brew install mysql. After installation I did brew link --force mysql and got Warning: Already linked: /usr/local/Cellar/mysql/8.0.19
I edited /usr/local/etc/my.cnf and added default-authentication-plugin=mysql_native_password in the [mysqld] section. After that I restartet the service using brew services restart mysql
brew services list shows me this now:
mysql started root /Library/LaunchDaemons/homebrew.mxcl.mysql.plist
mysql#5.7 stopped
However, when I type mysql in the terminal I get this:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
The /tmp/mysql.sock does not exist.
When I change the host in the my.cnf file from localhost to 127.0.0.1 this error will change into this:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 54
Anyone has an idea what's going on here and how I can fix it? I also googled it and found various Threads, some are saying that the permissions must be changed to this sudo chown -R _mysql:mysql /usr/local/var/mysql but this does not change anything in my case.
I install on my MacOS Sierra long time ago MySQL using brew install mysql and everytime I turn off and on my computer mysql started automagicaly what was great. But unfortunately yesterday I needed to temporarily shutdown MySQL - so I found on internet some command (but it was not brew services stop mysql) and after that when I reboot my computer MySQL not started (I was unable to connect by Sequel Pro GUI MySQL client). So I try to run it by:
brew services start mysql
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)
But I was still unable to connect :(
I try to connect by following command (to change root password) and get hint:
Mac-mini-Kamil:local Kamil$ mysqladmin -u root password 'xxxx'
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
I type this 'hint' to internet and find out that I need run the following command:
mysqld
And that works :) (I was able to connect to my db)
I installed LaMp 2 days ago. First everything works;
But until yesterday, I can't start anymore mysql server : it failed each time.
When I look at the status :
systemctl status mysql
Failed to get D-Bus connection: Erreur inconnue -1
It's like it can't generate mysqld.sock
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
I keep reading man and trying to find something I didn't configure correctly, but I can't find nothing.
Please, help me to resolve that problem.
Try to use this command in a terminal:
sudo service dbus restart
or this:
sudo /etc/init.d/dbus restart
Probably this is a temporary solution, this means that you'll have to do that command everytime you got the dbus error.