Installing Mysql in Ubuntu 16.06

To install MySQL manually in Linux, see steps below:

Installing MySQL 5.5.51 on Ubuntu 16.06

  1. Uninstall any existing version of MySQL
    sudo rm /var/lib/mysql/ -R
  2. Delete the MySQL profile
    sudo rm /etc/mysql/ -R
  3. Automatically uninstall mysql
    sudo apt-get autoremove mysql* --purge
    sudo apt-get remove apparmor
  4. Download version 5.5.51 from MySQL site
    wget https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz
  5. Add MySQL user group
    sudo groupadd mysql
  6. Add MySQL (not the current user) to MySQL user group
    sudo useradd -g  mysql mysql
  7. Extract mysql-5.5.51-linux2.6-x86_64.tar.gz to /usr/local
    cd /usr/local
    sudo tar -xvf mysql-5.5.49-linux2.6-x86_64.tar.gz
  8. Create MySQL folder in /usr/local
    sudo mv mysql-5.5.49-linux2.6-x86_64 mysql
  9. Set MySQL directory owner and user group
    cd mysql
    sudo chown -R mysql:mysql *
  10. Install the required lib package
    sudo apt-get install libaio1
  11. Execute MySQL installation script
    sudo scripts/mysql_install_db --user=mysql
  12. Set MySQL directory owner from outside the MySQL directory
    sudo chown -R root .
  13. Set data directory owner from inside MySQL directory
    sudo chown -R mysql data
  14. Copy the MySQL configuration file
    sudo cp support-files/my-medium.cnf /etc/my.cnf 
  15. Start MySQL
    sudo bin/mysqld_safe --user=mysql &
    sudo cp support-files/mysql.server /etc/init.d/mysql.server
  16. Initialize root user password
    sudo bin/mysqladmin -u root password '111111'
  17. Start MySQL server
    sudo /etc/init.d/mysql.server start
  18. Stop MySQL server
    sudo /etc/init.d/mysql.server stop
  19. Check status of MySQL
    sudo /etc/init.d/mysql.server status
  20. Enable MySQL on startup
    sudo update-rc.d -f mysql.server defaults
  21. Disable MySQL on startup (Optional)
    sudo update-rc.d -f mysql.server remove
  22. Add MySQL path to the system
    sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
  23. Now directly use the command below to start mysql
    mysql -u root -p 
    

PS: One needs to reboot in order for the changes to take place.

Start a Conversation

Your email address will not be published. Required fields are marked *