Install and configure Mysql5.7 and centos7mysql5.7 on Centos7
Step 1: Obtain the mysql YUM Source
Go to the mysql website to obtain the RPM package
Https://dev.mysql.com/downloads/repo/yum/
Right-click Copy link https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
Get the rpm package address
Step 2: download and install the mysql Source
First download the mysql source installation package
[root@localhost ~]# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
-Bash: wget: Command not found
Install wget first.
yum -y install wget
Then executewget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
Install mysql Source
yum -y localinstall mysql57-community-release-el7-11.noarch.rpm
Step 3: Install Mysql online
yum -y install mysql-community-server
You need to wait for a while to download more things;
Step 4: Start the Mysql Service
systemctl start mysqld
Step 5: Set startup
systemctl enable mysqldsystemctl daemon-reload
Step 6: Modify the root local Login Password
After mysql is installed, a temporary default password is generated for root in the/var/log/mysqld. log file.
vi /var/log/mysqld.log
The password here is: xtqh0Neteu = 7
mysql -u root -pEnter password:
Enter a temporary password to enter the mysql command line;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'LCode1996.';
Change the password to LCode1996. (Note: mysql5.7 the default password policy requires that the password must be a combination of uppercase and lowercase letters, numbers, and special letters, at least 8 characters)
Step 7: Allow Remote Login
Mysql does not allow remote logon by default. We need to set it and open port 3306 on the firewall;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'LCode1996.' WITH GRANT OPTION;Query OK, 0 rows affected, 1 warning (0.05 sec)mysql> exit;Bye
Exit;
[root@localhost ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanentsuccess[root@localhost ~]# firewall-cmd --reloadsuccess[root@localhost ~]#
Open Port 3306
Step 8: configure the default encoding to UTF-8
Modify the/etc/my. cnf configuration file and add the encoding configuration under [mysqld], as shown below:
[mysqld]character_set_server=utf8init_connect='SET NAMES utf8' [root@localhost ~]# vi /etc/my.cnf
Edit and restart the mysql service after saving: systemctl restart mysqld
Check the encoding below:
Mysql> show variables like '% character % ';
Step 9: Test
We use sqlyog on the local machine to remotely connect to mysql in the virtual machine.
Here, Mysql installation and configuration are complete;