Conor Mac Aoidh
http://macaoidh.name
conor@macaoidh.name
 
« Oh no!! Not.. IE6
Conor’s Management System »

MySQL – XAMPP

Posted Nov 30th, 2008 by Conor

I 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!

4 Responses to “MySQL – XAMPP”

  • Conor on 30 Nov 2008 at 10:03 pm

    I forgot to say.

    If you reboot and MySQL is no longer working don’t worry! Remember that you need to start XAMPP for MySQL to work. Start XAMPP:

    /opt/lampp/lampp start

  • Kae Verens on 01 Dec 2008 at 9:57 am

    installing MySQL doesn’t automatically start it running.

    Once you’ve installed it (“urpmi mysql” as you said), you then need to start it running. “service mysqld start” should work, and if not, then “/etc/init.d/mysqld start”.

    then, to make sure it starts every time you boot the machine, do “chkconfig –add mysqld”, or if you prefer, just add one of the service start commands noted above to /etc/rc.local

  • Kae Verens on 01 Dec 2008 at 9:58 am

    oh – should also note that mysql comes in two parts – client and server. “urpmi mysql” only installs the client part. you should replace also “urpmi mysql-server” to get the server part.

  • Reuel on 07 Sep 2009 at 6:47 pm

    Excellent tutorial…!!!I had solved my problem.

Comments RSS

Leave a Reply



Conor's Blog is powered by Wordpress | Template design by Conor Mac Aoidh