# install mysql 5.7.44 on ubuntu 22.04 from source tar.gz file + Remove existing MySQL + sudo apt remove --purge mysql* -y + sudo apt autoremove -y + sudo rm -rf /etc/mysql /var/lib/mysql + extract mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz file [ tar -xvzf mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz ] + install this file [ libaio1_0.3.113-4_amd64.deb, libncurses5_6.2-0ubuntu2_amd64.deb, libtinfo5_6.2-0ubuntu2_amd64.deb ] + libaio1_0.3.113-4_amd64.deb + sudo dpkg -i libaio1_0.3.113-4_amd64.deb + verify + ls -l /usr/lib/x86_64-linux-gnu/libaio.so.1, show message : [ lrwxrwxrwx 1 root root 15 Jan 18 2023 /usr/lib/x86_64-linux-gnu/libaio.so.1 -> libaio.so.1.0.2 ] + libncurses5_6.2-0ubuntu2_amd64.deb + sudo dpkg -i libncurses5_6.2-0ubuntu2_amd64.deb + verify + ls -l /usr/lib/x86_64-linux-gnu/libncurses.so.5, show message : [ lrwxrwxrwx 1 root root 17 Feb 26 2020 /usr/lib/x86_64-linux-gnu/libncurses.so.5 -> libncurses.so.5.9 ] + libtinfo5_6.2-0ubuntu2_amd64.deb + sudo dpkg -i libtinfo5_6.2-0ubuntu2_amd64.deb + verify + ls -l /lib/x86_64-linux-gnu/libtinfo.so.5, show message : [ lrwxrwxrwx 1 root root 15 Feb 26 2020 /lib/x86_64-linux-gnu/libtinfo.so.5 -> libtinfo.so.5.9 ] + mv mysql-5.7.44-linux-glibc2.12-x86_64 /usr/local/mysql + sudo groupadd mysql + sudo useradd -r -g mysql -s /bin/false mysql + sudo mkdir mysql-files + sudo chown mysql:mysql mysql-files + sudo chmod 750 mysql-files + cd mysql + cp support-files/mysql.server /etc/init.d/mysql + sudo mkdir /usr/local/mysql/data + sudo chown -R mysql:mysql /usr/local/mysql + sudo chown -R mysql:mysql data + chmod +x /etc/init.d/mysql + Initialize MySQL Data Directory (if not done) + cd /usr/local/mysql + sudo rm -rf data + sudo mkdir data + sudo chown -R mysql:mysql data + sudo ./bin/mysqld --initialize --user=mysql --basedir=$(pwd) --datadir=$(pwd)/data + start mysql + sudo /usr/local/mysql/bin/mysqld_safe --user=mysql --datadir=/usr/local/mysql/data & + /usr/local/mysql/bin/mysql -u root -p --socket=/usr/local/mysql/mysql.sock + reset root password + ALTER USER 'root'@'localhost' IDENTIFIED BY 'sap123ok'; + create user password sap + CREATE USER 'sap'@'%' IDENTIFIED BY 'sap123ok'; + GRANT ALL PRIVILEGES ON . TO 'sap'@'%' WITH GRANT OPTION; + FLUSH PRIVILEGES; + sudo ufw allow 3306/tcp [ if firewall on ] + check user + SELECT User, Host FROM mysql.user; + start mysql manual ./bin/mysqld_safe --defaults-file=./etc/my.cnf --user=mysql & + Start MySQL in safe mode (no password required) + ./bin/mysqld_safe --skip-grant-tables --skip-networking & + error check mysql + cd /usr/local/mysql/data + ls -l *.err + mysql status check + ps aux | grep mysqld # optionl for install GUI + install GUI on ubuntu server 25.04 + sudo apt update && sudo apt upgrade -y + Install Lightweight Desktop (XFCE) < sudo apt install xubuntu-desktop -y > + If prompted during install, choose your preferred display manager (usually gdm3 for GNOME or lightdm for XFCE/MATE). # when installing MySQL from .tar.gz, tar installs do NOT automatically create /etc/mysql/my.cnf. You must create the config file manually. sudo nano /etc/my.cnf ========================================= [mysqld] basedir=/usr/local/mysql datadir=/usr/local/mysql/data socket=/usr/local/mysql/mysql.sock port=3306 user=mysql # Optional but recommended bind-address=0.0.0.0 character-set-server=utf8mb4 collation-server=utf8mb4_general_ci [client] socket=/usr/local/mysql/mysql.sock ========================================= sudo pkill mysqld sudo /usr/local/mysql/bin/mysqld_safe & /usr/local/mysql/bin/mysql -u root -p # autostart mysql sudo nano /etc/systemd/system/mysql.service =================================================== [Unit] Description=MySQL Server After=network.target [Service] Type=forking User=mysql Group=mysql0 ExecStart=/usr/local/mysql/bin/mysqld_safe \ --basedir=/usr/local/mysql \ --datadir=/usr/local/mysql/data \ --socket=/usr/local/mysql/mysql.sock ExecStop=/usr/local/mysql/bin/mysqladmin \ --socket=/usr/local/mysql/mysql.sock \ -u root shutdown Restart=always LimitNOFILE=5000 [Install] WantedBy=multi-user.target =================================================== new: =================================================== [Unit] Description=MySQL Server After=network.target [Service] Type=forking User=mysql Group=mysql ExecStart=/usr/local/mysql/bin/mysqld \ --defaults-file=/etc/my.cnf ExecStop=/usr/local/mysql/bin/mysqladmin \ --socket=/usr/local/mysql/mysql.sock \ -u root shutdown Restart=always LimitNOFILE=5000 [Install] WantedBy=multi-user.target =================================================== sudo systemctl daemon-reload sudo systemctl enable mysql sudo systemctl start mysql sudo systemctl status mysql sudo reboot # ip address static ubuntu 22.04 + https://github.com/kiemGit/ip_address_ubuntu/tree/main # To restart networking on an Ubuntu Server without rebooting + If your server uses Netplan + sudo netplan apply