Ubuntu & LAMPP: How to share MySQL

Being used to using XAMPP for Windows, when I migrated to Ubuntu, I installed XAMPP for Linux (LAMPP). The only draw-back is that programs that need MySQL and don’t allow you to locate the sock file manually (like AmaroK) will complain and not let you use MySQL as a storage alternative.

For this, I learned about symlinks (symbolic links). But, since the fake mysqld directory always gets deleted by the time I log back in, I had to create a bash script that will run on boot and won’t require me to use sudo or put my password, it runs as root.

First, we create the script:

gedit mysql_link.sh

Then, our script is extremely simple:

#!/bin/bash
mkdir /var/run/mysqld
ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock

Now we make it executable and we move it to the init.d directory:

chmod +x mysql_link.sh
sudo mv mysql_link.sh /etc/init.d

And, now, we add it to be executed on boot time:

sudo update-rc.d mysql_link.sh defaults

Note that we didn’t add the full path to it.

Anyway, we can even do the same to start LAMPP on startup (in the same script or a different one, depending on your particular needs.)

Tags: , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: