prereq
Get repository
wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm sudo rpm -ivh mysql57-community-release-el7-11.noarch.rpmGet key mysql
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 rpm -qa gpg-pubkey* ls -l /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Install Mysql
Install mysql-server
sudo yum install mysql-serverBecause MySQL is automatically installed you can use OS command for service management, for example to check if it’s already started
sudo systemctl status mysqldStart MySQL if not started
sudo systemctl start mysqld sudo systemctl enable mysqld sudo systemctl status mysqld
Change root password
- Check the content of my.cnf, that is in default folder for linux OS and note the following info (lines that start with “#”are just comments)
- Where is the database and the error log (mysqld.log) stored?
- Check if there are error for the instance looking in the error log file
Starting from MySQL 5.7 the default installation of MySQL Server generates a one-time password. You find it in error log notes above
sudo grep 'temporary' /var/log/mysqld.logLogin to MySQL using password retrieved in previous step
mysql -uroot -p -h localhostTry to run a command and write down the error message
mysql>statusChange root password
mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'Welcome1!';Retry command above, now it works
mysql>status;Which databases are installed by default?
mysql>show databases;To see which version of MySQL you are using submit the command
mysql>show variables like "%version%";Check default users in standard installation
mysql>select user, host from mysql.user where user='root';Logout as ‘root’ and connect as admin
mysql>exit
Secure MySQL Installation
sudo mysql_secure_installation
Enter current password for root (enter for none):
Set root password? [Y/n] Y
New password:
Re-enter new password:
Do you wish ...? : Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y