Monday, March 24, 2014

Manually installing MySQL 5.7 in ubuntu

First we need to get the .deb installer, we can either use the system's GUI installer which is summoned by right clicking the file and choosing install, or install it by terminal:
sudo dpkg -i mysql-5.7.x-xYZ-ubuntu12.04-x86_64.deb

if you run into libaio dependencies issue install the libraries as follows:
sudo apt-get install libaio-dev

after this, the installation path would be
/opt/mysql/server-5.7

now let's add the mysql user and group into our server:
sudo groupadd mysql
sudo useradd -r -g mysql mysql

and place a link for local reference and setup the proper ownerships to install the db:
cd /usr/local
sudo ln -s /opt/mysql/server-5.7 mysql
cd mysql
sudo chown -R mysql:mysql . sudo scripts/mysql_install_db --user=mysql

now set final ownerships and configure system  service:
sudo chown -R root .
sudo chown -R mysql data
sudo ln -s `pwd`/support-files/mysql.server /etc/init.d/mysql
sudo update-rc.d mysql defaults

now you can start your server with
sudo service mysql start

usage for mysql service is:
mysql  {start|stop|restart|reload|force-reload|status}  [ MySQL server options ]