Category Archives: MySql

[Solved] ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

Xampp is my favourite webserver for linux as well as windows for web development works. And while importing huge mysql database dumps I use the commandline tool in windows as well as linux. And I often find myself so irritating to the error messages as follows :

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Error 2002 (Hy000)

When mysql is unable to find the appropriate socket to connect with the service, then we get the above error.

The above error can be solved by two different ways.
1. By specifying the correct socket in php.ini settings
2. By creating symbolic link to the appropriate socket file.

I will explain step 2 : How to view the correct socket file to create symbolic link ?

Use command below to identify the correct socket file in use

samundra@samundra-apple:~$ ps -aux | grep mysqld

Output will be something like below ::

root      6244  0.0  0.0   1912   572 pts/0    S    14:41   0:00 /bin/sh /opt/lampp/bin/mysqld_safe --datadir=/opt/lampp/var/mysql --pid-file=/opt/lampp/var/mysql/
nobody    6291  0.1  0.3  32636 13700 pts/0    Sl   14:41   0:09 /opt/lampp/sbin/mysqld --basedir=/opt/lampp --datadir=/opt/lampp/var/mysql --user=nobody --pid-file=/opt/lampp/var/mysql/ --skip-external-locking --port=3306 --socket=/opt/lampp/var/mysql/mysql.sock
samundra  8370  0.0  0.0   4160   856 pts/0    S+   16:01   0:00 grep --color=auto mysqld

See the screenshot below
MySql Process Dump
What we just did was that we first verified that the mysqld (service for mysql) is currently running and then we retreived the file in use by the process.

In above output we can see


This is the required file, where we will create our symbolic link. Now all we have to do is execute the following command.

samundra@samundra-apple:~$ cd /var/run/
samundra@samundra-apple:~$ sudo mkdir mysqld
samundra@samundra-apple:~$ ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock

See the screenshot below for symblic link pointing to the /opt/lampp/var/mysql/mysql.sock file.
Symbolic Link

The above has to be carried out each time you restart linux, so to make things easier what we can do is create a script and execute it manually. It can also be set to execute at boot time, You can google for that part.

I created a file having contents

sudo rm -rf /var/run/mysqld
sudo mkdir /var/run/mysqld
sudo ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysql.sock

then I changed the permission to execute.

samundra@samundra-apple:~$ chmod u+x

To execute use the following command:

samundra@samundra-apple:~$ ./

It will ask me my admins password and then will do the rest of the job of creating symbolic links and all.

[Solved] Phpmyadmin Vs commandline mysql import

Phpmyadmin allows GUI interface to import but it also depends on the browser because it runs on localhost, that is webserver so when importing huge amount of data the GUI of phpmyadmin seems to freeze, that browser stops responding.

  • If the file is of small size say around 10-20 MB it wouldn’t make any difference but if the file is of huge i.e. around 100+ MB, at that time it makes difference

As a solutions, we can increase the filesize import limit and execution time limit through php.ini.

And the other solution would be to use the mysql command line to import that is very efficient compared to the GUI for import i.e. in phpmyadmin.

The command is

$ mysql -u root -p -h localhost -D "databasename" < import.sql

Then you’ll be asked for password of mysql, supply your mysql password and wait for few seconds/minutes. The amount of time one has to wait depends on the amount of data which is being dumped. The higher the amount of data means higher the waiting time.

When your data has been successfully dumped you will get a command prompt, without any error messages, which means the data has been successfully dumped.

Above command works for both Windows as well as Linux. I have tried importing the 150 MB of file and it took me around 10 sec.

Hope this helps someone.

Minor Project SMS Banking in Java

SMS Banking Projects and Locus

We (Asee and Me )have kept stall in LOCUS ( Room no. 304 and getting nice feedback from the visitors. Our presentation went good and judges seemed to be happy. Volunteers were really very helpful and co-ordination was impressive. Today I knew why IOE students are good, because they have the environment which gives them opportunities to learn and explore themselves.

Since most of the friends have asked for the source-code of the program we thought of releasing the source and making it available for everyone so others can study our code. We agree our code is not so much efficient and hasn’t been well documented but the places were document is most has been documented. If you are thinking on implementing this code for commercial purpose, then we’ll not be responsible for any kind of damage caused by the use of these codes. There is no any kind of licensing. As long as you are happy to use these codes, you are all yourself.

Project on SMS banking requires some knowledge of AT Commands for controlling the GSM/GPRS Modem

Our project requirements are categoriesed into hardware and software.


1. Java Programming Langauge (Download Link)

2. Java Communication API (Please google and find it, start with

3. Eclipse IDE (Optional)

4. MySql Server (Download Link)

5. Mysql Connector for Java(Download Link)

Softwares listed above are available freely available but we’ll also need a hardware i.e. GSM/GPRS Modem, which costs around Rs. 10,000/- here in Nepal alternative would be to use cell phones that can be controlled through AT Commands.


1. GSM/GPRS Modem

GPRS Modem

2. Connectivity Cable for GSM Modem

We have tested our system in windows and haven’t tested it under linux environment, so you’ll have to manage yourself to get it working under linux environment, let me know if you have any difficulty in setting up, and I will try to assist you as much as I can.

Initial Setup

At first you have to install Java Development Kit ( JDK 7.0 ) then You’ll have to configure Java Communication API, this is the most annoying part of the project, and people find this quite confusing. (See How to configure Java Communication API-not available will write it down soon).

After configuring Java Communication API, you’ll have to install MySql Server in your system, this will be the backend database server for our project.

To connect MySql Server throguh java we’ll need MySql connector/J for Mysql developed by MySql Developers for Java.

(PS How to configure MySqlConnector/J for Java-not available will write it down soon).

Eclipse IDE

We have used Eclipse IDE as our primary IDE for development of this software, as eclipse is quite easy for project management and development tasks and it has got some quite nice features.

bove all are available freely but we’ll also need a hardware i.e. GSM/GPRS Modem, which costs around Rs. 10,000/- here in Nepal. We can also use mobile phones which can be controlled via AT Commands.

Here is the full sourcode for the project Download Full Sourcode Here

Here is the Github repository link

[ Solved ] Cannot connect to local MySQL server through socket

MySql Workbench Problem:

Test connection failed

Couldn’t load library cannot open shared file: No such file or directory

In both of these problems, the UI is unable to connect to local database server which was running in background. After searching in internet for solution and being to MySql official forum. I found this working solution for both problems stated above and I think it should work for similar kind of problem too.

Solution :

Create Symbolic Link

asee@asee-hp:~$ cd /usr/lib

asee@asee-hp:~$ sudo ln -s

After invoking those commands, re-start the applications and try creating the database connection, Now you should successfully get into database connection.

Drop comments if you have difficulty in gettting connected.

with best regards,