310
Q:

can't connect to local mysql server through socket '/var/run/mysqld/mysqld.sock'

> ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
> 
> service mysql start or service mysql start
2
# this saved my ass
# first  you must perform a graceful shutdown of the server from the command line rather than powering off the server
shutdown -h now

# an additional method for getting it back up again when you run into this problem is to move mysql.sock

# to centos
mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak

# to ubuntu
mv /var/run/mysqld/mysqld.sock /var/run/mysqld/mysqld.sock.bak

# restart mysql
service mysqld start
1
# Remove mysql
sudo apt-get remove --purge mysql\*

# Reinstall it
sudo apt install mysql-server mysql-client

# Test if it runs
sudo mysql

# You can install also thes pachages. Optionnaly
sudo apt install php7.4 php7.4-fpm php7.4-mysql php7.4-cgi php7.4-cli php7.4-common

#mesabo youbeyou
1
# Start your mysql server
/etc/init.d/mysql start
0
sudo apt-get install mysql-server
0
mysql -h 127.0.0.1 -P 3306 -u root -p <database>
0
service mysql start
0
Solution #1: Check If MySQL Service is Runnning.
Solution #2: Connect with 127.0. 0.1.
Solution #3: Modify the my. cnf file.
Solution #4: Verify mysql. sock Location.
Solution #5: Change MySQL Folder Permission.
Solution #6: Multiple MySQL Instances.
1
#/usr/sbin/mysqld --defaults-file=/etc/mysql/my.cnf --basedir=/usr --datadir=/var/lib/mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock
0
##	ERROR 2002 (HY000): 
##	Can't connect to local MySQL server through socket 

#### Follow below steps and you good to go... ####
sudo dpkg-reconfigure mysql-server-{version_number}
##version_number should be mysql version number installed
## Now try login in mysql shell
sudo mysql -u root -p
0

New to Communities?

Join the community