How to Install mysql 5.7 on centos 7 and change the root password
install mysql5.7 repo
yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
install the community server
yum install -y mysql-community-server
we want to set a default root password as mysql 5.7 comes with a default password. we set the environment option
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
start the mysql service
systemctl start mysqld
login and change the root password
mysql
mysql> UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPassword') WHERE User = 'root' AND Host = 'localhost';
mysql> FLUSH PRIVILEGES;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
mysql> quit
stop the service once again
systemctl stop mysqld
unset the environment option
systemctl unset-environment MYSQLD_OPTS
start the service
systemctl start mysqld
verify your installation
mysql -p
mysql> show databases;