MYSQL-CENTOS7 installation 1. Download the MySQL repo source
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
2. Install the MYSQL-COMMUNITY-RELEASE-EL7-5.NOARCH.RPM package
rpm -ivh mysql-community-release-el7-5.noarch.rpm
After installing this package, you will get two MySQL yum repo sources: /etc/yum.repos.d/mysql-community.repo
, /etc/yum.repos.d/mysql-community-source.repo
.
3. Install MySQL
yum install mysql-server
Follow the steps to install it, but after the installation is complete, the password is a random password and requires a password reset.
4. Start MySQL
systemctl start mysqld
Extension: Stop MySQL Service
systemctl stop mysqld
5. Connect to MySQL
No password in the initial state, can be entered directly
mysql -u root -p
Exit
quit
6. Reset Password
After exiting MySQL, the following command can reset the password, the first time you do not need to enter the password (because no password), the second time to enter a new password, confirm again, reset the password successfully.
mysqladmin -u root -p password<old password><new password><confirm new passowrd>
After resetting the password, you can log in with the new password connection.
7. Allow Remote connections
Tip: Configure the firewall to open 3306 ports
8. Modify the MySQL default port
(1) Log in to MySQL
mysql -u root -p<Enter Password>
(2) View port number
mysql>'port';+---------------+-------+|Variable_name|Value|+---------------+-------+|port |3306 |+---------------+-------+1 row in set (0.05 sec)
(3) Edit the /etc/my.cnf
file, add port parameters, and set the port, note that the port is not used, save to exit.
[email protected] /> vim /etc/my.cnf [mysqld]port=3506datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid
(4) Restart MySQL
systemctl restart mysqld
(5) Firewall open 9936 port for outside access
vim /etc/sysconfig/iptables# 添加下面这行代码-A INPUT -m state --state NEW -m tcp -p tcp --dport 9936 -j ACCEPT
MYSQL-CENTOS7 Installation Tutorials