MySQL – XAMPP
Posted Nov 30th, 2008 by Conor in in Linux, MandrivaI ran into great difficulties getting MySQL to work with the Konsole on Mandriva. I stayed up untill about 5am last night trying to get it to work to no avail. Finally this evening I hit a break through. After trauling through forums last night I found no answers – just millions of people asking the same question so I hope to answer it here!
Method 1
This method is recommended all over the internet and i’m sure it does work – but with a great work around. I spent a lot of time trying to get this to work and I couldn’t so I reverted to method 2 below. I strongly recommend trying method 2 because it simply just works! If anyone can point out what I’m doing wrong here please let me know.
Assuming that you have urpmi installed type the following:
urpmi mysql
Blah Blah Blah and it is installed. Now lets enter mysql.
mysql -u root -p
Enter Password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
No! I have got the infamous error 2002!
I spent so long trying to fix this error and in the end I estabalished that the mysql.sock file was simply never created. I could go on and list all the solutions that I tried that don’t work but at this point I think the best thing for you to do at this point is to uninstall.
urpme mysql
Good all’s good and now lets revert to method number 2 which actually does work without much trouble.
Method 2
Now this method is easy and will take no longer than five minutes. We are going to install a package called XAMPP which contains Apache 2.2.9, MySQL 5.0.67, PHP 5.2.6 and phpmyadmin among others. It is very usefull. To download just type:
wget http://kent.dl.sourceforge.net/sourceforge/xampp/xampp-linux-1.5.5a.tar.gz
Then to install:
tar xvfz xampp-linux-1.5.5a.tar.gz -C /opt
It should now be installed – simple as that! To start XAMPP:
/opt/lampp/lampp start
Starting XAMPP 1.5.5a…
LAMPP: Starting Apache…
LAMPP: Starting MySQL…
LAMPP started.
Now that it is started type http://localhost in your browser and there you go!
Now you have XAMPP working which has phpmyadmin which you can use for mysql. If you would rather have MySQL in a CLI (like me) then you can simply follow the instructions below.
MySQL will not work initially because you need to locate the mysql.sock file. To gain immediate access just type:
mysql -u root --socket=/opt/lampp/var/mysql/mysql.sock
Brilliant its working ! This is only a temporary fix however because you don’t want to have to type in the socket location every time. To set the socket location permenantly to the new location do the following:
vim /etc/my.cnf/
This will open up the documet. Type “i” to get into insertion mode (to edit the text). There are two sections here that you need to edit – client and mysqld. They both have a socket location, if you replace both of those locations with the new one (/opt/lampp/var/mysql/mysql.sock) it should do the job. Press escape to exit insertion mode and press “:wq” to exit and save. Now your MySQL should work by just typing:
mysql -u root -p
Hopefully that works for you, it did for me. As I said earlier I couldn’t find any decent solution online. If you see any problems with what I have written just let me know!