Uğur Kazdal

I'm a Linux Ent. Who loves PHP, Python, Go and So.

Install Damn Mysql To Centos And Get Root Password

» linux,, mysql

If you access to this web site for recovering mysql root password go to bottom of page

Sometimes it can be pain on the keyboard to handle mysql on Centos if you don’t follow instructions. So we need to focus on tutorials line by line. So Let’s start with Mysql On Centos,

First thing first, Which Mysql Version you need ? I prefer 5.7 but let’s continue for MySql 8.0 then we can move on for MySql 5.7

Enable MySQL 8.0 Repository and install


sudo yum localinstall https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
sudo yum install mysql-community-server

Enable for Mysql 5.7 and install


sudo yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
sudo yum install mysql-community-server

Now you can get your automatically generated Mysql root password by


sudo grep 'temporary password' /var/log/mysqld.log

And the output should looks like this (or uglier)

[Server] A temporary password is generated for [email protected]: %sasdS)(=)

Now we should do mysql_secure_installation to set new rules and password for root,


sudo mysql_secure_installation

Now can access mysqll by typing

mysql -u root -p 

Recover Mysql Root Password

Sometimes when you do not log any information for you systems, you forget your root password,

First stop your mysql service,


sudo systemctl stop mysql

Start the mysql without loading grant tables,

sudo mysqld_safe --skip-grant-tables --skip-networking &

Now you should able to login mysql without root password and set new mysql root password


sudo mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
FLUSH PRIVILEGES;

Now if everything should work fine you can restart mysql service,

sudo systemctl stop mysql
sudo systemctl start mysql

If you have any problem with mysql installation, setting new root password or recovering mysql root password. Just get in touch.