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

Installing MySQL In MAC OSX

With brew

brew install mysql

The above command installs the latest version of mysql, but if you need to install a specific version of mysql, you would use the following:

brew install mysql@5.7

After successful installation, you will see the following:

We've installed your MySQL database without a root password. To secure it run:

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

To have launchd start mysql now and restart at login:
  brew services start mysql
Or, if you don't want/need a background service you can just run:
  mysql.server start