Centos7 installation and configuration mysql5.7
First step: Obtain mysql YUM source
Enter the mysql official website to obtain the RPM package download address
https://dev.mysql.com/downloads/repo/yum/
Right click to copy link address https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
Get the address of the rpm package
Step 2: Download and install 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
We first install wget
yum -y install wget
Then execute wget 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
There are a lot of downloads, so wait a while;
Step 4: Start Mysql service
systemctl start mysqld
Step 5: Set boot up
systemctl enable mysqld systemctl daemon-reload
Step 6: Modify root local login password
After the mysql installation is complete, 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 -p Enter password:
Enter the temporary password to enter the mysql command line;
ALTER USER'root'@'localhost' IDENTIFIED BY'LCode1996.';
Change the password to LCode1996. (Note that the default password policy of mysql5.7 requires that the password must be a combination of uppercase and lowercase alphanumeric special letters, at least 8 digits)
Step 7: Set to allow remote login
Mysql does not allow remote login by default, we need to set it up and open port 3306 in 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 --permanent success [root@localhost ~]# firewall-cmd --reload success [root@localhost ~]#
Open port 3306
Step 8: Configure the default encoding as UTF-8
Modify the/etc/my.cnf configuration file and add the encoding configuration under [mysqld], as shown below:
[mysqld] character_set_server=utf8 init_connect='SET NAMES utf8' [root@localhost ~]# vi/etc/my.cnf
After editing and saving, restart mysql service: systemctl restart mysqld
Check the code:
mysql> show variables like'%character%';
Step 9: Test
We use the local sqlyog to remotely connect to the mysql in the virtual machine
Here, Mysql installation and configuration is complete;
0 Comments