Problems connecting to mysql on debian, error 2002 - mysql

I'm trying to run a mysql connection, and I am getting this error:
ERROR: Unable to connect to mysql: (2002) Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
I have been checking on other forums etc, and yes i checked if mysql server is running, and yes it is running ok,no portblocking, but what i see strage is that i dont ahve mysql.sock in my /var/lib/mysql directory.
I appreciate any sign of help.

Related

mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

I have mysql database which was working fine earlier. After getting too many connections error. I have increased max connection and restarted my centos server. But after restart I used below command to connect to server.
mysql -uroot -p
But I am getting below errors.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2).
I tried all the options available on google. But it didn't worked for me. Some are saying to reinstall mysql, but I have data in GB's which I don't want to lost. Please can anyone help me to solve this problem.Thanks in advance.
Make sure you are indexing the right socket file.
Try this and provide the output.
check the socket in the my.cnf
cat /etc/my.cnf | grep -i socket

mysql_secure_installation ERROR 2002 Can't connect to local MySQL server

After installing Mariadb on Debian 9, I am trying to run /usr/bin/mysql_secure_installation. The script starts okay, but after I press 'enter' for no root password, I get the following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")
I have to ctl-c to get out of the script.
The socket is set in /etc/mysql/debian.cnf to /var/run/mysqld/mysqld.sock
It is also set in /etc/mysql/mariadb.conf.d/50-server.cnf to /var/run/mysqld/mysqld.sock
The server is not running.
After digging around many, many places, the answer was right under my nose on the Troubleshooting Connection Issues page at the MariaDB website 1
The error means that the server is either not running or running on a different port, socket or pipe. Since I knew the server was not running, I started it with
/etc/init.d/mysql start
before running the script and no more problems with the error or the script.

After system update getting error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'

error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
I have been tried most off solutions given for above error but i am not able to connect mysql server. It had been working before my ubuntu system update.
I found the problem, The mysql library update stucks. That is why mysql server updating process not be completing.
When i check command "ps aux | grep mysql", i got process list of mysql update stuck processing as in given below image
click here to show image
So, when i killed those both processes(pid=6728 and 7041), I am able to connect mysql server easily.

Unable to start MySQL

I am using a virtual machine (ubuntu12.04) with Vagrant for development purposes. I had installed Apache, PHP and MySQL - which all originally worked. Now, MySQL seems to not work.
When I check the stasus by using sudo service mysql status:
mysql stop/waiting.
I tried to restart MySQL:
stop: Unknown instance
start: Job failed to start
While trying to connect via mysql -u root -p:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (111)
I have gone through different questions related to this issue on this site but most solutions are referring to a memory space problem (which is not in my case).

Connection to database failed! Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Hello i been running into this error after moving my website to a new host
[DonationSystem] Connection to database failed! Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I am running on the same version of linux ub 12.04 the server one.
i have a few databases running that are working such as my phpbb one.
i have tried link them edit configs and everything else the internet has told me even removed mysql and reinstalled it so any ideas?
oh and the database is local and im using localhost and root is the user