MySQL 8.0.20 Source Compilation and Installation on BClinux for Euler
Before proceeding, ensure your system meets minimum requirements: dual-core CPU, 2GB RAM (4GB+ recommended for concurrent services), and at least 30GB of free disk space.
1. Remove Conflicting Database Packages
MySQL and MariaDB share similar binaries and configurations, leading to conflicts. Uninstall any existing database packages:
yum list installed | grep -E "(mariadb|mysql)"
yum remove -y mariadb* mysql*
rm -f /etc/my.cnf
Verify removal by confirming no packages remain:
rpm -qa | grep -E "(mariadb|mysql)"
2. Configure Local YUM Repository
Since the system has no internet access, use a locally mounted ISO to provide packages.
Upload the BClinux for Euler 21.10 ISO to /mnt and mount it:
mkdir -p /mnt/BClinux
mount -o loop /mnt/BCLinux-for-Euler-21.10-everything-x86_64.iso /mnt/BClinux
Backup existing repo files and create a new local repository configuration:
cd /etc/yum.repos.d/
mv *.repo *.bak
cat > local.repo <<EOF
[local]
name=Local BClinux Repository
baseurl=file:///mnt/BClinux
enabled=1
gpgcheck=0
EOF
yum clean all
yum makecache
yum repolist
3. Install Required Build Dependencies
MySQL 8.0 requires specific development tools and libraries. Install them via the local repo:
yum install -y \
gcc gcc-c++ \
cmake3 \
bison bison-devel \
ncurses-devel \
libaio libaio-devel \
openssl openssl-devel \
zlib-devel \
flex \
perl \
perl-Module-Build \
perl-Module-Pluggable \
perl-Pod-Escapes \
perl-Pod-Simple \
perl-libs \
perl-version \
libtirpc-devel \
rpcsvc-proto-devel \
rpcgen \
lrzsz curl wget tar vim unzip zip git
Verify versions:
gcc --version
cmake3 --version
Insure GCC is ≥5.3 and CMake ≥3.75. The system’s GCC 7.3.0 and CMake 3.16.5 are sufficient.
4. System Configuration
Disable SELinux and firewall to avoid interference during installation:
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
systemctl stop firewalld
systemctl disable firewalld
Reboot the system to apply SELinux changes.
5. Download and Extract MySQL Source
Download mysql-boost-8.0.20.tar.gz from Oracle’s archive and transfer it to /usr/local/src. Alternatively, use wget if internet access is available:
cd /usr/local/src
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-boost-8.0.20.tar.gz
tar -xzf mysql-boost-8.0.20.tar.gz
cd mysql-8.0.20
mkdir build && cd build
Creating a separate build directory prevents cluttering the source tree and simplifies cleanup.
6. Configure with CMake
Execute the CMake configuration with optimized flags:
cmake3 .. \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/etc \
-DMYSQL_USER=mysql \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_DEBUG=0 \
-DMYSQL_MAINTAINER_MODE=0 \
-DWITH_SYSTEMD=1 \
-DDOWNLOAD_BOOST=0 \
-DWITH_BOOST=../boost
INSTALL_PREFIX: MySQL installation rootMYSQL_DATADIR: Data storage locationMYSQL_USER: Service runtime userWITH_BOOST: Points to bundled Boost source (required for 8.0.20)WITH_SYSTEMD=1: Enables systemd service management
7. Compile and Install
Compile using all available CPU cores for optimal speed:
make -j$(nproc)
make install
Compilation may take 10–90 minutes depending on hardware.
8. Prepare System User and Directories
Create the mysql user and necessary directories with correct ownership:
useradd -r -m -s /bin/bash mysql
mkdir -p /data/mysql /var/log/mysqld /var/run/mysqld
chown -R mysql:mysql /usr/local/mysql /data/mysql /var/log/mysqld /var/run/mysqld
9. Configure MySQL
Create /etc/my.cnf:
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql
socket=/tmp/mysql.sock
port=3306
[mysqld_safe]
log-error=/var/log/mysqld/mysqld.log
pid-file=/var/run/mysqld/mysql.pid
Grant sudo access to the mysql user for administrative tasks:
visudo
# Add line:
mysql ALL=(ALL) NOPASSWD: ALL
10. Set Environment Variables
Add MySQL binaries to PATH:
echo 'export MYSQL_HOME=/usr/local/mysql' >> /etc/profile
echo 'export PATH=$PATH:$MYSQL_HOME/bin' >> /etc/profile
source /etc/profile
mysql --version
11. Initialize the Database
Generate initial data and root password:
mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
Record the auto-generated temporary root password from the log:
grep 'temporary password' /var/log/mysqld/mysqld.log
12. Install systemd Service
Copy the service file and set permissions:
cp /usr/local/src/mysql-8.0.20/build/support-files/mysql.server /usr/lib/systemd/system/mysqld.service
chmod 644 /usr/lib/systemd/system/mysqld.service
systemctl daemon-reload
13. Start MySQL and Secure Instalation
Start the service and connect using the temporary password:
systemctl start mysqld
systemctl status mysqld
netstat -tlnp | grep 3306
mysql -uroot -p
Change the root password immediately:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourStrongPassword123!';
Enable remote access (optional):
USE mysql;
UPDATE user SET host='%' WHERE user='root';
FLUSH PRIVILEGES;
14. Enable Auto-Start and Verify
systemctl enable mysqld
systemctl restart mysqld
Test connectivity and data insertion:
CREATE DATABASE testdb;
USE testdb;
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50));
INSERT INTO users VALUES (1, 'Alice');
SELECT * FROM users;
15. Troubleshooting
Missing rpcgen
If CMake fails with "Could not find rpcgen", install the missing package:
yum install -y rpcgen rpcsvc-proto-devel
C++17 Compatibility Errors
If compilation fails with fatal error: charconv: No such file or directory, enforce C++17 standard:
cmake3 .. -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON
make clean
make -j$(nproc)
This error typical occurs with newer MySQL versions (e.g., 8.0.38+) on older toolchains. Using MySQL 8.0.20 avoids this issue entirely.
Installation is complete. MySQL is now running as a systemd service with proper permissions, data directories, and remote access configured.