After running the command
mysql -v
in Ubuntu, I am getting the following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
After running the command
mysql -v
in Ubuntu, I am getting the following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I think this is because you are using client software and not the server.
mysql
is clientmysqld
is the serverTry:
sudo service mysqld start
To check that service is running use: ps -ef | grep mysql | grep -v grep
.
Uninstalling:
sudo apt-get purge mysql-server
sudo apt-get autoremove
sudo apt-get autoclean
Re-Installing:
sudo apt-get update
sudo apt-get install mysql-server
For all the editors who make edits without any understanding of the subject: Please stop attempting to move this section to the top!
Previous steps did not work, anything else I can try?
You could delete apt.conf.d folder and pull updates again. This is only needed in rare cases. It was much more common back in 2016 when this answer was originally written. Before executing following commands take a backup of entire folder, make a copy of it, or create an archive of it:
### EXECUTING THE FOLLOWING COMMAND CAN CAUSE HARM TO YOUR SYSTEM
### UNDERSTAND WHAT YOU ARE DELETING BEFORE PROCEEDING
sudo rm /etc/apt/apt.conf.d/50unattended-upgrades*
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mysql-server
? –
Kurbash sudo apt-get purge mysql-server
. This is a good step to run Autoclean and autoremove: sudo apt-get autoremove && sudo apt-get autoclean
. Not to install run: sudo apt-get update && sudo apt-get install mysql-server
. Hope this helps. –
Kurbash 50unattended-upgr*
and re-run update & install. Updating all packages wouldn't hurt as well. See update to my answer. –
Kurbash sudo apt-get update sudo apt-get install mysql-server
is enough –
Caracole sudo apt-get upgrade
triggered a message asking if I wanted to replace the deleted 50unattended-upgrades file with the manufacturer version. This defaults to no, so make sure you enter Y if you want that file to be replaced. –
Poetize By default, apt install MariaDB but not mySQL.
sudo apt install default-mysql-server
If you would like to install real mySQL database by apt, follow these steps.
Firstly, we need to remove all preceding mysql installed on the host.
sudo apt-get --purge autoremove "^mysql.*"
Dowload the stable package mysql-apt-config_0.8.15-1_all.deb from
sudo wget https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb
Install the downloaded release package:
sudo dpkg -i mysql-apt-config_0.8.15-1_all.deb
Refresh your apt package cache to make the new software packages available
sudo apt update
Install MySQL by executing:
sudo apt-get update
sudo apt-get install mysql-server mysql-client
libmysqlclient-dev
Check mysql status:
sudo service mysql status
sudo dpkg -i mysql-apt-config_0.8.15-1_all.deb
for last version from https://dev.mysql.com/downloads/repo/apt/
and just edit version number –
Saraisaraiya Yes, should try reinstall mysql, but use the --reinstall
flag to force a package reconfiguration. So the operating system service configuration is not skipped:
sudo apt --reinstall install mysql-server
sudo apt reinstall mysql-server
–
Meyer I fixed by "purging" every file related to mysql and reinstalling mysql-server:
sudo apt-get purge mysql-server mysql-client mysql-common
sudo apt-get install mysql-server
Navigate to /etc/systemd/system/
and do the following
sudo rm -rf mysql.service
sudo rm -rf mysqld.service
You can try this command
sudo systemctl start mysql.service
Try running
sudo apt-get install mysql-server
if not installed.
I tried this also and more (re-installation etc.)
The answer was :
I found query_cache_limit
and removed it from the /etc/mysql/my.cnf
file.
As soon as I removed it, the error log changed to a query_cache_size one
so I removed that one too from my.cnf
file.
Within seconds, MySQL restarted successfully and I was back in business.
* Query Cache Configuration
query_cache_limit = 1M
query_cache_size = 16M
* Logging and Replication
#
I also faced same issue, and i restarted my Ubuntu 20 and mysql worked normally
© 2022 - 2024 — McMap. All rights reserved.