Číst česky →

How to install MySQL server 5.5.62 (Debian 11, Ubuntu 22.04)

1 min read Hukot net Linux Basics VPS MySQL

This tutorial also works on other versions of MySQL server in branch 5.5.x.

The next two commands irreversibly delete all MySQL or MariaDB databases and settings on the server. If you have data on it, back it up first, for example with sudo mysqldump --all-databases > backup.sql.

Uninstall any existing version of MySQL

sudo rm /var/lib/mysql/ -R

Delete the MySQL profile

sudo rm /etc/mysql/ -R

Automatically uninstall mysql

Uninstalling AppArmor disables the security profiles of every service on the server, not only MySQL.

sudo apt-get autoremove 'mysql*' --purge
sudo apt-get remove apparmor

Download version 5.5.62 from MySQL site

wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.5.62-linux-glibc2.12-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 the tar file

sudo tar -xvf mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz

Move it to /usr/local

sudo mv mysql-5.5.62-linux-glibc2.12-x86_64 /usr/local/

Create mysql folder in /usr/local by moving the untarred folder

cd /usr/local
sudo mv mysql-5.5.62-linux-glibc2.12-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 'new_password'

Add mysql path to the system

sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql

Start mysql server

sudo /etc/init.d/mysql.server start
sudo /etc/init.d/mysql.server status

Enable myql on startup

sudo update-rc.d -f mysql.server defaults

Install mysql client

sudo apt-get install default-mysql-client

Now login using the below command, start MySQL server if it’s not running already

mysql -u root -p