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.
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-libsInstall MySQL 8.0
Method 1
Use the latest package manager.
dnf install @mysql -yMethod 2
Install via yum.
yum install mysql-server -yVerify MySQL Installation
ps -ef | grep mysql
mysqladmin --versionEnable MySQL Service at Boot
Run the following command after installation: systemctl enable mysqld Check if MySQL is running:
systemctl status mysqldStart MySQL Service
systemctl start mysqldCheck status:
systemctl status mysqldRelated 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.cnfLogin to MySQL Without Password
mysql -urootReset 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 -pRemote 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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
