Install mysql5.7 and remote access under Linux
Preface
(After reading this blog post, if you don’t know how to install mysql, come and beat me!!!) The
project environment was set up in the company’s linux environment for the third time, and it took some time to install mysql5.7 this time. Information, in order to facilitate the quick installation of mysql in linux in the future, as well as change the password, configure remote access, hereby record this blog post very carefully.
1. Install mysql5.7 under Linux
1.1 Download
mysql official website: https://dev.mysql.com/downloads/mysql/5.7.html#downloads
1.2 Unzip and install
Unzip the installation package
tar -xvf mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar
Install in order :
rpm -ivh mysql-community-server-5.7.30-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-5.7.30-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-client-5.7.30-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-common-5.7.30-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-compat-5.7.30-1.el7.x86_64.rpm --force --nodeps
The details are as follows:
1.3 Start mysql and access
Start the mysql service:
systemctl start mysqld
Check the mysql service status after startup:
ps -aux|grep mysqld
Join startup:
systemctl enable mysqld
systemctl daemon-reload
The specific operation can refer to the following figure:
1.4 View the default mysql password
cat /var/log/mysqld.log |grep 'temporary password'
1.5 Change password
The database was initialized successfully, and the default password must be changed for the first time to enter the operation. As shown in the figure below, due to the simple password and password, I failed many times in the actual operation. Finally, the red box was successfully changed.
Use the modify password command:
SET PASSWORD = PASSWORD('password');
1.6 Authorize root to be accessed remotely
Allow root to be accessed remotely
grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;
Refresh permissions
flush privileges;
Restart the mysql service
service mysqld restart