1 Introduction
In the past, every new environment installation was Baidu, so that the installation method may be different every time, and may not be successful at one time. In order to save time in the future, so record the CentOs
installation MySQL
method today . Take CentOs 7
an example here .
2. Add yml source
The current mainstream MySQL of the project is still 5.7, so 5.7 is also installed here
Download the source installation package
wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
installation:
yum localinstall mysql57-community-release-el7-11.noarch.rpm
3. Install and start the service
installation:
yum -y install mysql-community-server
The download is a bit slow, even if you switch the source, it's almost the same, just have a cup of coffee or do something else.
Start the service:
systemctl start mysqld
Set power-on auto-start
systemctl enable mysqld
4. Modify the default password
View the default password:
grep 'temporary password' /var/log/mysqld.log
log in:
mysql -u root -p密码
Modify the default password:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'youPassword';
5. Open the remote connection
Allow a user to connect remotely and refresh permissions
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
flush privileges;
Turn on the firewall and open port 3306
systemctl start firewalld.service
firewall-cmd --permanent --remove-port=3306/tcp
Other related firewall commands:
systemctl start firewalld
: Turn on the firewallfirewall-cmd --add-port=8080/tcp --permanent
: Open port 8080firewall-cmd --reload
:Reloadfirewall-cmd --query-port=123/tcp
: Query whether the specified port is successfully openedfirewall-cmd --permanent --remove-port=123/tcp
: Close the designated portfirewall-cmd --zone=public --list-ports
: View all open ports
Reference:
https://segmentfault.com/a/1190000018442644