Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install MySQL 5.5.xx on Ubuntu

MySQL Download URL

https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz

Open the terminal and follow along:

  • Uninstall any existing version of MySQL
sudo rm /var/lib/mysql/ -R
  • Delete the MySQL profile
sudo rm /etc/mysql/ -R
  • Automatically uninstall mysql
sudo apt-get autoremove mysql* --purge
sudo apt-get remove apparmor
  • 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
  • Add mysql user group
sudo groupadd mysql
  • Add mysql (not the current user) to mysql user group
sudo useradd -g mysql mysql
  • Extract it
sudo tar -xvf mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz
  • Move it to /usr/local
sudo mv mysql-5.5.56-linux-glibc2.5-x86_64 /usr/local/
  • Create mysql folder in /usr/local by moving the untarred folder
cd /usr/local
sudo mv mysql-5.5.49-linux2.6-x86_64 mysql

  • set MySql directory owner and user group
cd mysql
sudo chown -R mysql:mysql *
  • Install the required lib package (works with 5.6 as well)
sudo apt-get install libaio1
  • Execute mysql installation script
sudo scripts/mysql_install_db --user=mysql
  • Set mysql directory owner from outside the mysql directory
sudo chown -R root .
  • Set data directory owner from inside mysql directory
sudo chown -R mysql data
  • Copy the mysql configuration file
sudo cp support-files/my-medium.cnf /etc/my.cnf
  • Start mysql
sudo bin/mysqld_safe --user=mysql &
sudo cp support-files/mysql.server /etc/init.d/mysql.server
  • Set root user password
sudo bin/mysqladmin -u root password '[your new password]'
  • Add mysql path to the system
sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
  • Reboot!

  • Start mysql server

sudo /etc/init.d/mysql.server start
  • Stop mysql server
sudo /etc/init.d/mysql.server stop
  • Check status of mysql
sudo /etc/init.d/mysql.server status
  • Enable myql on startup
sudo update-rc.d -f mysql.server defaults

*Disable mysql on startup (Optional)

sudo update-rc.d -f mysql.server remove
  • REBOOT!

  • Now login using below command, start mysql server if it's not running already

mysql -u root -p
@ValentinMerlet

This comment has been minimized.

Copy link

commented Jan 23, 2019

Thanks for this gist, you saved my day !

@YairPR

This comment has been minimized.

Copy link

commented Apr 23, 2019

Thanks !!

@prabir09

This comment has been minimized.

Copy link

commented Apr 25, 2019

Thanks for the gist.

@godfreymakori

This comment has been minimized.

Copy link

commented May 7, 2019

Thanks. Saved the day while reinstalling a legacy system

@aonomike

This comment has been minimized.

Copy link

commented Jun 8, 2019

can this be used for mysql 5.6 as well?

@noonedeadpunk

This comment has been minimized.

Copy link

commented Jun 19, 2019

@leandromeira

This comment has been minimized.

Copy link

commented Jun 28, 2019

You sir are a absolute legend for creating this. Flawless. Thank you very very much

@ahmadhasankhan

This comment has been minimized.

Copy link
Owner Author

commented Jun 30, 2019

can this be used for mysql 5.6 as well?

Yes, it should work.

@cherrypj

This comment has been minimized.

Copy link

commented Jul 16, 2019

Good stuff.

@Michael67780

This comment has been minimized.

Copy link

commented Sep 3, 2019

Great! Thank you )

@luisdaher

This comment has been minimized.

Copy link

commented Sep 12, 2019

Awesome gist. Thanks a lot!

@Mqleaf

This comment has been minimized.

Copy link

commented Sep 28, 2019

Can it work for MySQL 5.6 on Ubuntu 18.04? @ahmadhasankhan

@derisrayan

This comment has been minimized.

Copy link

commented Oct 10, 2019

Thank you Sir Ahmad (y)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.