Configuring MySQL 8 in RedHat Linux

After successful installation of MySQL 8 in your RedHat Linux, here are some of the common next steps, you might want to do as a Database administrator:

  1. Change ‘root’ user password

MySQL creates a temporary password for the default ‘root’ user during installation. The first thing you want to do is to change that password for the root user using the temporary password which you can get from /var/log/mysqld.log . To change the password, run mysql_secure_installation from the terminal

2. Create a database

Now, you can log in to the your database by using the following command from your terminal:

mysql -u root -p

use the password that created in step 1. To create a database:

mysql> create database db1

3. Create a user and grant the user all access to db1

mysql> create user ‘user1’@’%’ identified by ‘user_pass’;

mysql> grant all privileges on db1.* to ‘user1’@’%’ with grant option;

4. Changing database host port

MySQL configurations was pulled from any of these files: /etc/my.cnf, /etc/mysql/my.cnf, ~/.mysql/my.cnf . Edit the files and add or modify the port variable. For example:


Be sure to restart mysql server:

shell>sudo service mysqld restart

5. Back up all tables of database

shell>mysqldump db1 > backup-file.sql

6. Load tables to a database from the dump file

shell>mysql -u user1 -p db_name < backup-file.sql

In case, you wanna connect to the mysql server remotely, you can do so using a command-line mysql client by:

shell> mysql -u user1 -h host-name_or_ipaddress -P portnumber -D database_name -p