MySQL 5.7 on Fedora 25/26 from scratch

Hello fellow DBAs, tech enthusiasts and anybody who wants to know how to install MySQL 5.7 on Fedora 25/26 or any equivalent RPM based Linux distro.


Installing the Repo

Let’s start by installing the dummy package that gives us access to the MySQL Community repo using the following command:

# dnf -y install

Installing the server

After that’s done, just install the server as follows

# dnf -y install mysql-community-server

Once the server is installed and you have the service running, you may have noticed that no root password was given to the installation process, meaning that you’ll have to reset it manually. This is a good exercise on how to recover (or reset) ROOT passwords that have been forgotten.

Changing the ROOT password

Follow the steps described bellow:

  1. Stop the server
  2. Set the –skip-grant-tables option
  3. Start the server
  4. Update the password directly on the mysql.user table
  5. Flush the privileges.
  6. Stop the server
  7. Unset the option
  8. Start the server
  9. (Optional) Set the password if you are asked for it.
# systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

# systemctl start mysqld

$ mysql -u root

mysql> UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword') WHERE user = 'root' and host = 'localhost';


# systemctl stop mysqld

# systemctl unset-environment MYSQLD_OPTS

# systemctl start mysqld

Now you can login with your new ROOT password!

If you get this error

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

Execute this command

set password = PASSWORD('MyNewPassword');



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s