My problem started off with me not being able to log in as root any more on my mysql install. I was attempting to run mysql without passwords turned on... but whenever I ran the command Show
I would never get the prompt back. I was trying to follow these instructions to recover the password. The screen just looks like this:
and I don't get a prompt to start typing the SQL commands to reset the password. When I kill it by pressing CTRL + C, I get the following message:
If I retry the command and leave it long enough, I do get the following series of messages:
But then if I try to log in as root by doing:
I get the following error message:
I checked and Also, I don't know if
this helps or not, but I ran
I'm new to Linux and MySQL, so I don't know if this is normal or not. But I'm including this info just in case it helps. I finally decided to uninstall and reinstall mysql.
After reinstalling all packages again in the same order as above, during the phpmyadmin install, I got the same error:
So I tried again to uninstall/reinstall. This time, after I uninstalled the packages, I
also manually renamed all mysql files and directories to
Then I tried to reinstall Introduction Users working with MySQL can run into the error 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock (2)' when logging into the MySQL interface. This problem usually arises if MySQL can't access the mysqld.sock socket file. In this tutorial, we will go over the potential causes of the 'Can't connect to local MySQL server through socket' error and show you different methods of resolving this issue. Prerequisites
Resolving the 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' ErrorThere are multiple ways to solve the 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock (2)' error. If one solution doesn't work, move down the list until you find the one that resolves the issue. Method 1: Check the MySQL Service1. Check the status of the MySQL service with:
2. If the service is not running, restart it by using:
3. To prevent this issue from happening, set the MySQL service to automatically start at boot:
Method 2: Verify the mysqld.sock LocationThe 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' error also happens if MySQL can't find the mysql.sock socket file. 1. Find the current
mysqld.sock location by using the
2. Open the MySQL configuration file in a text editor of your choice. In this example, we use nano:
3. Then, add the following lines at the end of the MySQL configuration file:
Where:
Another method is to create a symlink from the location of mysqld.sock to the /var/run/mysqld directory:
4. Press Ctrl+X to close the configuration file and type Y and press Enter to save the changes you made. 4. Finally, restart the MySQL service:
Method 3: Check the MySQL Folder PermissionAnother potential cause could be that the MySQL Service can't access the /var/run/mysqld directory due to permission restrictions: 1. To resolve this issue, change the permission settings for the mysqld directory with:
Setting the permission to 2. Restart the MySQL service for the changes to take effect:
Method 4: Check for Multiple MySQL InstancesThe error also occurs if there are multiple instances of MySQL running at the same time. 1. To list all the instances of MySQL, use:
2. If there are multiple MySQL instances running, terminate them with:
3. Restart the MySQL service to start a single instance of MySQL:
Conclusion After reading this tutorial, you should have identified the cause of the 'Can't connect to local MySQL server through socket' error and applied the appropriate solution. For more help with using MySQL, consult our MySQL Commands Cheat Sheet. How do I connect to a local mysql server through socket?On the server host in the command line, run the following command: mysql -u root -p -h 127.0.0.1 -e "select @@socket". Type a password for your root user and press Enter .. Can not connect to mysql through socket?normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server. You should also check that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.
Can't connect to local mysql server through socket '[ path to mysqld sock ]'?How to Fix 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'. Method 1: Check the MySQL Service.. Method 2: Verify the mysqld.sock Location.. Method 3: Check the MySQL Folder Permission.. Method 4: Check for Multiple MySQL Instances.. Can't connect to mysql server through socket Ubuntu?"Try" to run mysql via /etc/init. d/mysql start if it gives you the exact same error from above then you need to copy the mysql. server file from the mysql you downloaded which can be found in the support-files folder inside the mysql folder you downloaded or in the /usr/local/mysql folder and copy it to /etc/init.
|