Skip to main content
3 of 5
fix command formatting
filbranden
  • 22.6k
  • 4
  • 65
  • 87

Install MYSQL 5.7 using bash script with Centos

I'm a little new to linux. I'm using Centos 7 and trying to write a script that will install mysql 5.7 during a vagrant setup. I know how to change the root password manually, but how do you write this in a script?

I have this already:

wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum -y localinstall mysql57-community-release-el7-7.noarch.rpm
yum -y install mysql-community-server
service mysqld start

Here is what I know to do manually: Get the temp password

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

Then I type and enter pass at prompt

mysql -u root -p
Enter Passwword:

Then change the pass or run the mysql_secure_installation

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Newhakase-labs123@';
flush privileges;
user204588
  • 131
  • 1
  • 5