preface
The RedHat system automatically configures yum.
Check whether MySQL is installed on the host
[root@vultr ~]# yum list installed | grep mysqlMysql - libs. X86_64 5.1.73-8 el6_8 @ CentOS / 6.10Copy the code
If the system has its own MySQL, delete it
[root@vultr ~]# yum -y remove mysql-libs.x86_64
Copy the code
Check whether MySQL is installed on the host using RPM
[root@vultr ~]# rpm -qa | grep -i mysql-i: the match is case insensitive. 1) If there is an RPM package installed MySQL, run the following command to delete it: [root@vultr ~]RPM -e --nodeps package name[root@vultr ~]# find / -name mysql
[root@vultr ~]# rm -rf directory
[root@vultr ~]# rm -rf /etc/my.cnfMySQL > install MySQL [root@vultr ~]# rpm -qa | grep -i mysql
Copy the code
Execute in any directory
[root@vultr ~]# wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
Copy the code
Install RPM files
[root@vultr ~]# rpm -ivh mysql-community-release-el6-5.noarch.rpm
Preparing... # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%]
1:mysql-community-release# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%]
Copy the code
6. X system yum install MySQL, install 5.1, so you need to manually change the yum information. Repo = mysql-community. Repo = mysql-community. Repo = mysql-community. Repo = mysql-community.
Check whether the MySQL installation file is already available
[root@vultr ~]# yum repolist all | grep mysql. [omitted] mysql55-community-source MySQL 5.5 community Server - Sour mysql56-community MySQL 5.6 community Server 512 mysql56-community-source MySQL 5.6 community Server - Sour [Omitted]Copy the code
You can see that mysql56-community is enabled
Install the mysql server
[root@vultr ~]# yum install -y mysql-community-server
Copy the code
Waiting for installation…
After the installation is successful, start the mysql service
[root@vultr ~]# service mysqld start
Copy the code
Log on to the mysql
The password is not set at the first login. You can log in to mysql -u root directly.
[root@vultr ~]# mysql -u root
Copy the code
Set the password and enable remote login
mysql> use mysql
mysql> update user set password=password('Your password') where user='root'; Mysql > grant all PRIVILEGES on *.* to 'root' @ '%' identified by 'your password' with grant option; mysql> flush privileges;Copy the code
Open port 3306
[root@vultr ~]# vi /etc/sysconfig/iptablesAdd -a INPUT -p TCP -m state --state NEW -m TCP --dport 3306 -j ACCEPT :wq Save and exit [root@vultr ~]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
Copy the code
Set startup (personal preference)
[root@vultr ~]# chkconfig mysqld on
Copy the code