MariaDB is installed by default in CentOS, but what we need is MySQL. Installing MySQL can overwrite MariaDB
The MariaDB database management system is a branch of MySQL, which is mainly maintained by the open source community and is licensed under GPL. One of the reasons for the development of this branch is that after Oracle acquired MySQL, there is a potential risk of closing MySQL to the source, so the community uses branching to avoid this risk. The purpose of MariaDB is to be fully compatible with MySQL, including API and command line, so that it can easily become a substitute for MySQL.
First install the Yum Repository of MySQL
Yum helped us manage the dependencies of various rpm packages. It is a rpm-based package manager that can automatically download and install RPM packages from a specified server. It can automatically handle dependencies and install all dependent software packages at once. No need to download and install again and again.
All operations are switched to the root user
Install MySQL official Yum Repository
[ root@localhost~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
Download rpm package
[ root@localhost~]# yum -y install mysql57-community-release-el7-10.noarch.rpm
Install MySQL service
[ root@localhost~]# yum -y install mysql-community-server
It takes a long time to perform the installation service. Please wait patiently. I asked y/n? Enter y and enter
Start the mysql service:
[ root@localhost~]# systemctl start mysqld.service
View the running status of mysql:
[ root@localhost~]# systemctl status mysqld.service
You can see the running status of the mysql service, and the following information appears, where Active represents the status after the service is started, which is active (running), and after it is stopped, it is inactive (dead)
[ root@localhost ~]# systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running)since March 2018-02-14 10:12:13 CST; 3min 31s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 1424 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 935 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 1427 (mysqld)
CGroup: /system.slice/mysqld.service
└─1427 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid...
2 Month 14 10:11:53 localhost.localdomain systemd[1]: Starting MySQL Server...
2 Month 14 10:12:13 localhost.localdomain systemd[1]: Started MySQL Server.
You can also restart the service
root@localhost~]# service mysqld restart
Out of service
[ root@localhost~]# systemctl stop mysqld.service
After the installation is complete, there is a root user by default, the initial password has been set, we need to obtain this initial password to log in and then modify it
In order to enhance security, MySQL 5.7 randomly generates a password for the root user. In the error log, regarding the location of the error log, if the RPM package is installed, the default is /var/log/mysqld.log.
You can view the temporary password only after starting mysql once
Check the initial password by the following command, the character after the colon is the password
grep 'temporary password'/var/log/mysqld.log
Login root user
[ root@localhost~]# mysql -u root -p
Prompt for the password, enter the initial password, after using the password, you need to set your own password, but mysql has a password requirement, we want to set a simple password must modify the constraints, modify two global parameters:
validate_password_policy represents the password policy, the default is 1: meet the length, and must contain numbers, lowercase or uppercase letters, special characters. Set to 0 to determine the standard of the password based on the length of the password. Be sure to modify the two parameters first and then modify the password
mysql> set global validate_password_policy=0;
validate_password_length represents the length of the password, the minimum value is 4
mysql>setglobal validate_password_length=4;
Change the password to root, and then you can use that password to log in
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
The syntax command is as follows: enable zone port and protocol combination
firewall-cmd [--zone=<zone>]--add-port=<port>[-<port>]/<protocol>[--timeout=<seconds>]
This will enable the combination of ports and protocols.
The port can be a single port or a range of ports -.
Protocol can be tcp or udp
Check firewalld status
systemctl status firewalld
Open firewalld
systemctl start firewalld
Open port
// --permanent,Invalid after restart without this parameter
firewall-cmd --zone=public--add-port=3306/tcp --permanent
firewall-cmd --zone=public--add-port=1000-2000/tcp --permanent
Reload
firewall-cmd --reload
View
firewall-cmd --zone=public--query-port=80/tcp
delete
firewall-cmd --zone=public--remove-port=80/tcp --permanent
Recommended Posts