Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Offline MySQL Server Installation on Kylin Linux

Tech 1

Pre-Installation Preparation

First, obtain the MySQL 8.x binary tarball optimized for Linux x86_64 with glibc 2.12+ from an external trusted source. Transfer the compressed archive to a dedicated directory on your Kylin system, such as /usr/local/, using USB, SCP, or other file transfer tools.

Extract and Organize Installation Files

Navigate to the directory containing the tarball and extract it using a modified command that avoids unnecessary details in output:

cd /usr/local/
tar -xf mysql-8.0.33-linux-glibc2.28-x86_64.tar.xz
ln -s mysql-8.0.33-linux-glibc2.28-x86_64 mysql-server

Create a symbolic link for easier command access without version-specific folder names.

System Account and Directory Setup

Next, add a dedicated non-root system user and group for MySQL operation, then set up required data and log directories:

groupadd mysql-system
useradd -r -g mysql-system -s /sbin/nologin -d /nonexistent mysql-system
mkdir -p /data/mysql/datadir /data/mysql/logs
chown -R mysql-system:mysql-system /data/mysql /usr/local/mysql-server
chmod 750 /data/mysql

Core Configuration File

Create or edit /etc/my.cnf using nano instead of vi for simpler text editing, inserting basic but functional parameters:

[mysqld]
basedir=/usr/local/mysql-server
datadir=/data/mysql/datadir
socket=/data/mysql/mysql.sock
log-error=/data/mysql/logs/mysqld-error.log
pid-file=/data/mysql/mysqld.pid
port=3306
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci

[client]
socket=/data/mysql/mysql.sock

Save and exit the editor.

Database Initialization

Initialize the data directory using the dedicated system user, wich will generate a temporary root password stored in the error log:

/usr/local/mysql-server/bin/mysqld --initialize --user=mysql-system
grep 'temporary password' /data/mysql/logs/mysqld-error.log

Record the temporary password displayed after root@localhost: for later use.

Service Management Setup and Startup

Create a systemd service file to manage MySQL automatically, rather than using mysqld_safe:

nano /etc/systemd/system/mysqld.service

Paste the following content into the file:

[Unit]
Description=MySQL Community Server
After=network.target syslog.target

[Service]
Type=forking
User=mysql-system
Group=mysql-system
ExecStart=/usr/local/mysql-server/bin/mysqld --daemonize --pid-file=/data/mysql/mysqld.pid
ExecStop=/usr/local/mysql-server/bin/mysqladmin shutdown
Restart=on-failure

[Install]
WantedBy=multi-user.target

Save and exit. Then reload systemd, enable MySQL to start on boot, and launch the service immediately:

systemctl daemon-reload
systemctl enable mysqld
systemctl start mysqld
systemctl status mysqld

Post-Installation Verification and Password Reset

Log into MySQL using the temporary root password:

/usr/local/mysql-server/bin/mysql -uroot -p

Reset the temporary password to a secure custom one, then flush privileges to apply changes:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourStrongPassword123!';
FLUSH PRIVILEGES;
EXIT;

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.