Installing MySql on Ubuntu 14.04
Published 6 years and 1 month ago, Categorized under: Linux, MySQL

TBH, installing mysql does not need that much of work, but it will not work if you try to install it on a small VPS (512MB) so I will let you know what to do.

Creating Swap

To be able to use mysql on a small VPS you will need to create a swap for it, you are free to use the following script, which I have created.

Its not 100% perfect, but it worked

create a shell file and call it


echo "create the swapfile dev"
sudo dd if=/dev/zero of=$SWAPFILENAME bs=1024 count=524288
echo "make swap for $SWAPFILENAME"
sudo mkswap $SWAPFILENAME

echo "changing the permission for $SWAPFILENAME"
sudo chown root:root $SWAPFILENAME
sudo chmod 0600 $SWAPFILENAME

echo "Turn the swapon for $SWAPFILENAME"

sudo swapon $SWAPFILENAME
echo "now you should add the following line to your /etc/fstab, you will need to do that as root"

echo "$SWAPFILENAME swap swap defaults 0 0"
echo "sudo nano /etc/fstab"

execute the command

sudo sh

and then remember to edit fastab file to add the swap to it and you are done.

Installing MySql

You can install it like any other linux package using APT package manager .

$ apt-get install -y mysql-server-5.6

after the script finish, you can try to secure it by executing the following command

$ mysql_secure_installation

to access mysql from the command line

$ mysql -u root -p

and that's it.

Share It via: