There are countless tutorials on installing mysql database on Linux on the Internet, but most of them are full of loopholes. Today, in order to help those who need it, I wrote a tutorial on installing and configuring mysql5.7 on Centos7.
Recommended related mysql video tutorials: "mysql tutorial"
The first step: Get the 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 the link address https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
Get the address of the rpm package
Recommended Manual:MySQL Development Manual
Step 2: Download and install mysql source
Download mysql first Source installation package
[root@localhost ~]# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
-bash: wget: command not found
Let’s install wget first
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
It will take a while to download a lot of things;
Step 4: Start the Mysql service
systemctl start mysqld
Step 5: Set up startup
systemctl enable mysqld systemctl daemon-reload
Recommended related articles:
1.Installing mysql under CentOS7 Detailed steps for -server
2.How to install mysql and php in Centos7
Related video recommendations:
1.MySQL authoritative development Guide
Step 6: Modify the root local login password
After the mysql installation is completed, in the /var/log/mysqld.log file A temporary default password is generated for root.
vi /var/log/mysqld.log
mysql -u root -p Enter password:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'LCode1996.';
Step Seven: Set to allow remote login
Mysql does not allow remote login by default. We need to set it up and open the firewall to port 3306;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
[root@localhost ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent success [root@localhost ~]# firewall-cmd --reload success [root@localhost ~]#
Step 8: Configure the default encoding to UTF-8
Modify the /etc/my.cnf configuration file and add it under [mysqld] Encoding configuration, as shown below:[mysqld] character_set_server=utf8 init_connect='SET NAMES utf8' [root@localhost ~]# vi /etc/my.cnf
Step 9: Test
We use the local sqlyog remote connection Download mysql in the virtual machine## At this point, Mysql installation and configuration is complete;
Related recommendations:
Mysql5.7 Detailed explanation of how to modify the data location under Windows 7mysql5.7 detailed installation graphic processMySQL Basic tutorial mysql5.7.18 installation and connectionThe above is the detailed content of How to install and configure Mysql5.7 on Centos7. For more information, please follow other related articles on the PHP Chinese website!