/ MYSQL

Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

You might have came across this error when you tried development of Ruby on Rails project with MySQL as your development database.

What is the Error '/tmp/mysql.sock'?

This file is required for your application to get connected to your MySQL database.

Basically Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2) this error can come when your MySQL server is not started.

You can start you MySQL server by using following command:

Command to start MySQL Server

mysql.server start

This will start your MySQL server and it will create the file‘/tmp/mysql.sock’ which is required for your application to get connected to the MySQL server.

The output after you hit enter by above command is:

Starting MySQL
. SUCCESS!

**which indicates successful start of your MySQL server.

This will solve the error Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2). Then you just have to restart your application.

Command to Stop MySQL Server:

mysql.server stop

The result of above operation:

Shutting down MySQL
.. SUCCESS!

You can read more commands regarding MySQL server in this post.

Comments are welcome.

akshay

Akshay Mohite

Hi there! I am a Ruby on Rails & ReactJS Enthusiast, building some cool products at DTree Labs.

Read More
Buy me a coffee