Databases 6 min read

How to Install and Configure MySQL 8.0 on Linux: Step‑by‑Step Guide

Learn how to completely uninstall any existing MySQL, install MySQL 8.0 via dnf or yum, verify the installation, configure it to start on boot, manage root passwords, and set up remote access with Navicat, all with clear commands and screenshots.

Open Source Linux
Open Source Linux
Open Source Linux
How to Install and Configure MySQL 8.0 on Linux: Step‑by‑Step Guide

Table of Contents

Check Existing Installation (Force Uninstall)

Install MySQL 8.0

Verify MySQL Installation

Enable MySQL Service at Boot

Start MySQL Service

Related Installation Directories

Login to MySQL Without Password

Reset root Password

Login Again with New Password

Remote Connection with Navicat

Check Existing Installation (Force Uninstall)

for i in $(rpm -qa|grep mysql); do rpm -e $i --nodeps; done
rm -rf /var/lib/mysql && rm -rf /etc/my.cnf && rm -rf /usr/share/mysql && rm -rf /var/log/mysql
# optional: whereis mysql
# optional: find / -name mysql
yum remove mysql mysql-server mysql-libs

Install MySQL 8.0

Method 1

Use the latest package manager.

dnf install @mysql -y

Method 2

Install via yum.

yum install mysql-server -y

Verify MySQL Installation

ps -ef | grep mysql
mysqladmin --version

Enable MySQL Service at Boot

Run the following command after installation: systemctl enable mysqld Check if MySQL is running:

systemctl status mysqld

Start MySQL Service

systemctl start mysqld

Check status:

systemctl status mysqld

Related Installation Directories

# View MySQL related commands
cd /usr/bin/
pwd
find my*

# View configuration file directory
cd /usr/share/mysql/
pwd
ls -lh

# Database files directory
cd /var/lib/mysql/
pwd
ls -lh

# MySQL startup configuration files
cd /etc/my.cnf.d/
pwd
ls -lh
# client config: client.cnf
# daemon config: mysql-server.cnf
# default auth plugin config: mysql-default-authentication-plugin.cnf

Login to MySQL Without Password

mysql -uroot

Reset root Password

# Select database
use mysql;
# Change password (MySQL 8.0 syntax)
alter user 'root'@'localhost' identified by 'root';
# Refresh privileges
flush privileges;

Before change:

After change (root password set to "root"):

Login Again with New Password

mysql -uroot -p

Remote Connection with Navicat

Note: Open port 3306 or disable the firewall first.

Grant all privileges to root for remote access:

# If error occurs, modify host in mysql.user table
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

Update host value:

update user set host='%' where user='root';
flush privileges;

Navicat can now connect successfully.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxmysqlService ManagementRemote accessNavicatRoot PasswordDatabase Installation
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.