CentOS 7.6 – Install MySQL 5.7
Learning nodeJS will inevitably involve mysql, so I have installed mysql on my server to record the process of installing mysql and the problems encountered in the process.
Server environment
Centos System Version
# cat /proc/version
Linux version 3.10.0-957.27.2.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Mon Jul 29 17:46:05 UTC 2019
Copy the code
version
# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
Copy the code
Installation steps
Checks whether all child repositories in the MySQL Yum repository already exist
rpm -qa|grep mysql
Copy the code
If you already have all the child repositories corresponding to MySQL, skip the next step of downloading the Yum resource bundle
Download the Yum resource package
The mysql version I want to install is 5.7.27-1*
rpm -ivh http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
Copy the code
MySQL installation
Use the following command to start the MySQL server:
yum install mysql-community-server
Copy the code
Yum -y install mysql-server yum -y install mysql-server yum -y install mysql-server yum -y install mysql-server yum -y install mysql-server
This will install the MySQL server package as well as any other required packages.
Start MySQL server
Use the following command to start the MySQL server:
service mysqld start
Copy the code
You can use the following command to check the status of the MySQL server:
service mysqld status
Copy the code
Log in to MySQL/ Security Settings
After installation, root has a default password in the /var/log/mysqld.log file. It can be printed by using the following command:
grep 'temporary password' /var/log/mysqld.log
2019-08-08T07:37:46.357258Z 1 [Note] A temporary password is generated for root@localhost: dy*pjAmKa0gr
Copy the code
As in my output above, dy*pjAmKa0gr is the default password.
Log in with a generated temporary password and set a custom password for the superuser account:
mysql -uroot -p
Copy the code
Change root password as soon as possible:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4! ';
Copy the code
Note that MySQL validate_password is installed by default. This will require the password to contain at least one uppercase letter, one lowercase letter, one number, and one special character, and the total password length must be at least eight characters.
Exit and restart MySQL to take effect.
service mysqld start
Copy the code
Log in to MySQL again with the new password
mysql -uroot -p
Copy the code
The next step is to look at the operation of SQL statements
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rowsin set(0.00 SEC) mysql >exit
Bye
Copy the code
CentOS automatically starts MySQL upon startup
systemctl enable mysqld
Copy the code
Cow force! The next step is to continue to operate MySQL with nodeJS.
Reference documentation
Dev.mysql.com/doc/mysql-y…