MySQL Server Installation
MySQL Server Installation
Download the desired version of MySQL from the official MySQL website.
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.xx-linux-
glibc2.xx-x86_64.tar.xz
6. Configure MySQL
Create a custom configuration file /app/mysql/my.cnf to define the custom basedir and
datadir.
sudo vi /app/mysql/my.cnf
[mysqld]
basedir=/app/mysql
datadir=/app/mysql/data
port=3306
socket=/app/mysql/mysql.sock
log-error=/app/mysql/mysql-error.log
pid-file=/app/mysql/mysql.pid
sudo vi /etc/systemd/system/mysql.service
[Unit]
Description=MySQL Server
After=network.target
[Service]
User=mysql
Group=mysql
ExecStart=/app/mysql/bin/mysqld --defaults-file=/app/mysql/my.cnf
LimitNOFILE=5000
[Install]
WantedBy=multi-user.target
9. Secure MySQL
/app/mysql/bin/mysql_secure_installation
10. Verify Installation
/app/mysql/bin/mysql -u root -p
This process allows you to install and configure MySQL in a custom directory, making it
independent of the default /usr paths.