Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to start the mysql server in ubuntu

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)

like image 210
Rohit Kumar Avatar asked Dec 14 '16 16:12

Rohit Kumar


People also ask

How fix MySQL is not starting?

Try manually start the service from Windows services, Start -> cmd.exe -> services. msc. Also try to configure the MySQL server to run on another port and try starting it again. Change the my.


Video Answer


4 Answers

I think this is because you are using client software and not the server.

  • mysql is client
  • mysqld is the server

Try: 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

Backup entire folder before doing this:

sudo rm /etc/apt/apt.conf.d/50unattended-upgrades*
sudo apt-get update
sudo apt-get upgrade
like image 140
Dmitri Sandler Avatar answered Oct 25 '22 11:10

Dmitri Sandler


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
like image 33
danilocgsilva Avatar answered Oct 25 '22 12:10

danilocgsilva


Try running

sudo apt-get install mysql-server 

if not installed.

like image 21
Sreelakshmi Radhakrishnan Avatar answered Oct 25 '22 12:10

Sreelakshmi Radhakrishnan


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
like image 27
Duc Toan Pham Avatar answered Oct 25 '22 11:10

Duc Toan Pham