I have googled for 2 days now and was initially get a
'/var/run/mysqld/mysqld.sock' (2)
I fixed this by using:
sudo touch /var/run/mysqld/mysqld.sock
sudo chown -R mysql /var/run/mysqld/
now i get the error:
'/var/run/mysqld/mysqld.sock' (13)
So everything has the correct permissions and the file exists. Any thoughts?
[Edit]
Got it working, although i am unsure how. I did aa-logprof
as root
, nothing changed, got angry and then re-set it started working.
To fix the MySQL socket issue and access denied error for root@localhost , follow the below steps. Stop the MySQL server by executing the command “ sudo service mysql stop “. Create socket location as a placeholder by executing the command “ sudo mkdir -p /var/run/mysqld “.
Another possible solution to the >can't connect to local mysql server through socket> error message is to try and connect to the MySQL using the 127.0. 0.1 ip address instead of localhost. When you use localhost to connect to MySQL, the operating system uses the socket connector.
The MySQL server's socket file is named mysqld. sock and on Ubuntu systems it's usually stored in the /var/run/mysqld/ directory. This file is created by the MySQL service automatically.
In my case, running mysqld_safe
created a new mysqld.sock
file.
$ cd /etc/init.d/
$ mysqld_safe
You'll probably won't get the prompt back, but if you restart your session, a mysqld.sock file will be somewhere. Find it with
$ sudo find / -type s | grep mysqld.sock
You cannot (absolutely cannot) replace the filesystem pipe /var/run/mysqld/mysql.sock
with a regular file. You need to use mkfifo(1)
to create the pipe(7)
that clients use to communicate with the mysql server.
The (13)
probably also means that you have a permission denied error return, EACCES
(which usually has the decimal value 13
-- yes, I've seen it a lot).
If the file system permissions are configured correctly, you might be having accesses rejected by a mandatory access control tool such as AppArmor, SELinux, TOMOYO, or SMACK.
AppArmor comes pre-installed on Ubuntu systems by default, and might be rejecting access to the pipe. Check /var/log/syslog
, /var/log/audit/audit.log
or dmesg(1)
output for messages that look something like this:
type=AVC msg=audit(1320723925.179:45115): apparmor="DENIED"
operation="open" parent=1 profile="/usr/sbin/ntop"
name="/usr/share/ntop/html/PlotKit/excanvas.js" pid=1835 comm="ntop"
requested_mask="r" denied_mask="r" fsuid=122 ouid=0
(But with name=/var/run/mysqld/mysql.sock
instead.)
If you have error messages like this, run aa-logprof
as root
and answer the questions. More information on configuration AppArmor can be found in the apparmor.d(5)
manpage, or some various wiki pages.
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