in this tutorial, We’ll Learn how to fix MySQL ERROR 2002 Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock
.
Normally, This issue will occur when you connect the MySQL server through the command line, you might encounter a MySQL ERROR 2002 as follows:
mysql -uroot -proot
ERROR 2002 (HY000): Can’t connect to local MySQL server
through socket '/tmp/mysql.sock'
(2)
If the mysql.sock
socket file is not there in your filesystem, the ERROR 2002 that was mentioned above will appear.
When the MySQL server is started, this file is created, and it is deleted when the server is stopped.
Please verify MySQL server is already installed and running on your computer.
if not installed then Please installed by following the below step
Let’s install mysql-server
and the mysql package using the
below command.
apt-get install mysql-server mysql
Once you have the server installed, run the server with the following command:
sudo service mysql start OR sudo /etc/init.d/mysql start
The command will start the MySQL database server and create a mysql.sock
file.
Let’s verify MySQL service is running in the Services panel.
Step 1: Open the Windows Start menu and search for the Services panel to see the result below:
Step 2:
Scroll through the services list until you reach the MySQL services
Step 3: Check the status of the service if it’s stopped: you can run the service by clicking the Start the service link on the left pane. Otherwise, restart the MySQL server service.
You probably need to start the server in order for it to operate because the socket file is created when the MySQL server is started.
Now you can try to connect again to your MySQL server from the Command Line.
This tutorial helps integrate a PHP SDK with Laravel. We'll install aws-php-sdk into laravel application and access all aws services… Read More
in this quick PHP tutorial, We'll discuss php_eol with examples. PHP_EOL is a predefined constant in PHP and represents an… Read More
This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More
We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More
in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More
I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More