Deploying MySQL 8.0 on CentOS 7: A Step-by-Step Walkthrough

Prerequisites and Initial Setup

Start with a minimal CentOS 7 environment to avoid conflicts. Create a temporary workspace for the installation bundle.

mkdir -p /mysql
cd /mysql
wget https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar
tar -xvf mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar

Cleaning Up Existing MariaDB or MySQL Libraries

Before installing, remove conflicting packages that ship with CentOS by default.

Identify installed MariaDB components:

rpm -qa | grep -i mariadb

Typical output:

mariadb-libs-5.5.65-1.el7.x86_64

Purge every matching package forcefully:

rpm -ev --nodeps mariadb-libs-5.5.65-1.el7.x86_64

Remove obsolete MySQL libraries and install required system depandencies:

yum remove mysql-libs
yum install net-tools -y
yum -y install perl.x86_64
yum install -y libaio.x86_64

Installing MySQL 8.0 Packages in Sequence

A strict order is mandatory to satisfy internal dependencies: comon, libs, client, then server.

rpm -ivh mysql-community-common-8.0.16-2.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.16-2.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.16-2.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.16-2.el7.x86_64.rpm

If you encounter a libnuma.so related error, install the numactl package and retry:

yum -y install numactl

Starting the MySQL Service

Use service or systemctl to control the daemon. Start the server first:

service mysqld start

Other management commands:

service mysqld stop
service mysqld restart
service mysqld status

Retrieving and Changing the Temporary Root Password

MySQL 8 generates a random initial password stored in the error log.

cat /var/log/mysqld.log | grep password

Log in with the temporary credentials:

mysql -uroot -p

Enforce a strong password containing uppercase, lowercase, digits, and special characters:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Atlassian@2023';

The core installation is now complete. The following sections cover optional configuration tasks.

Enabling Remote Connections

Grant network access to the root user (adjust user and host as needed):

USE mysql;
SELECT host, user FROM user;
UPDATE user SET host = '%' WHERE user = 'root';
FLUSH PRIVILEGES;

Open port 3306 in the firewall:

firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload

Also verify cloud security group rules and any local iptables policies if connections remain blocked.

Customizing the MySQL Configuration

The default settings file is /etc/my.cnf. Edit it using:

vim /etc/my.cnf

For Atlassian tools (Jira, Confluence, Bitbucket), append the following under the [mysqld] section and restart MySQL:

default-storage-engine=INNODB
character_set_server=utf8mb4
collation-server=utf8mb4_bin
max_allowed_packet=256M
innodb_log_file_size=2GB
innodb_default_row_format=DYNAMIC
binlog_format=row
log_bin_trust_function_creators=1
transaction-isolation=READ-COMMITTED

Creating a Database with utf8mb4 Support

CREATE DATABASE jira CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;

Relocating the Data Directory

1. Move the data and adjust permissions

service mysqld stop
mv /var/lib/mysql /data
chmod -R 777 /data/mysql/

2. Update the configuration file

Edit /etc/my.cnf so that datadir and socket point to the new location:

datadir=/data/mysql
socket=/data/mysql/mysql.sock

3. Restart the service

service mysqld start

If startup fails, temporarily disable SELinux:

setenforce 0

To permanently disable SELinux, change SELINUX=disabled in /etc/selinux/config and reboot the system.

Tags: MySQL 8 CentOS 7 database installation Linux

Posted on Mon, 18 May 2026 17:50:33 +0000 by FURQAN