Last active
June 18, 2024 21:26
-
-
Save jniltinho/dff879cef642c8353e3a9fee103d47bf to your computer and use it in GitHub Desktop.
Install Mysql 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Install Mysql 5.5.62 Debian 12 | |
## https://downloads.mysql.com/archives/community/ | |
## https://downloads.mysql.com/archives/get/p/23/file/mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz | |
## https://www.hukot.net/community/en/tutorials/how-to-install-mysql-server-5-5-62-on-debian-ubuntu | |
## This tutorial also works on other versions of MySQL server in branch 5.5.x. | |
## Uninstall any existing version of MySQL; It's not mandatory | |
## rm /var/lib/mysql/ -R | |
## Delete the MySQL profile | |
## rm /etc/mysql/ -R | |
apt update | |
apt install libncurses5 curl wget libaio1 | |
## Automatically uninstall mysql, It's not mandatory | |
# apt autoremove mysql* --purge | |
# apt 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 and user | |
groupadd mysql && useradd -g mysql mysql | |
## Extract the tar file | |
tar -xvf mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz | |
## Move it to /usr/local | |
mv mysql-5.5.62-linux-glibc2.12-x86_64 /usr/local/mysql | |
## set MySql directory owner and user group | |
chown -R mysql:mysql /usr/local/mysql | |
# Execute mysql installation script | |
cd /usr/local/mysql && scripts/mysql_install_db --user=mysql | |
## Set data directory owner from inside mysql directory | |
chown -R mysql:mysql /usr/local/mysql | |
## Copy the mysql configuration file | |
mkdir /etc/mysql | |
cp /usr/local/mysql/support-files/my-medium.cnf /etc/mysql/my.cnf | |
## Start mysql | |
cd /usr/local/mysql && bin/mysqld_safe --user=mysql & | |
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql.server | |
## Set root user password | |
/usr/local/mysql/bin/mysqladmin -u root password 'new_password' | |
## Add mysql path to the system | |
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile | |
export PATH=$PATH:/usr/local/mysql/bin | |
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/ | |
ln -s /usr/local/mysql/bin/mysql_config /usr/local/bin/ | |
## Start mysql server | |
/etc/init.d/mysql.server start | |
/etc/init.d/mysql.server status | |
## Enable myql on startup | |
update-rc.d -f mysql.server defaults | |
## Install mysql client It's not mandatory | |
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment