Centos uses yum to install mysql and centosyummysql
Reference: http://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
1. Add a yum Data Source
(1.1) getting the right data source from the http://dev.mysql.com/downloads/repo/yum/
(1.2) install the data source package
shell> sudo rpm -Uvh platform-and-version-specific-package-name.rpm
Eg: InstallationRed Hat Enterprise Linux 7/Oracle Linux 7 (Architecture Independent), RPM Package
shell> wget http://repo.mysql.com/mysql57-community-release-el7-7.noarch.rpmshell> sudo rpm-Uvh mysql57-community-release-el7-7.noarch.rpm
2. Select the appropriate installation version
(2.1) view the packages in the mysql Data Source
shell> sudo yum repolist all | grep mysql
(2.2) edit/etc/yum. repos. d/mysql-community.repo to enable the corresponding mysql version
# Enable to use MySQL 5.6[mysql56-community]name=MySQL 5.6 Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/enabled=0gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql[mysql57-community]name=MySQL 5.7 Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Ps: "enabled = 1" enabled, "enabled = 0" disabled, the above configuration is to install "mysql 5.7", disable "mysql 5.6"
(2.3) view the mysql activation list
shell > sudo yum repolist enabled | grep mysqlmysql-connectors-community/x86_64 MySQL Connectors Community 17mysql-tools-community/x86_64 MySQL Tools Community 27mysql57-community/x86_64 MySQL 5.7 Community Server 20
3. Install mysql
shell> sudo yum install mysql-community-server
Note: During mysql 5.7 installation using yum, a temporary root password is randomly generated and saved to the error log ("/var/log/mysqld. log "), you can use the following command to view:
shell > sudo grep 'temporary password' /var/log/mysqld.log
Therefore, after installing mysql 5.7, you need to change the password as soon as possible.
4. Start the mysql server
shell> yum --disablerepo=\* --enablerepo='mysql*-community*' list available
(4.1) Start command
shell> sudo service mysqld start
(4.2) view mysql status
shell> sudo service mysqld status
5. mysql_secure_installation
Use mysql_secure_installation to set the root password and delete anonymous users.
shell> mysql_secure_installation
Ps: more operations
Http://dev.mysql.com/doc/refman/5.7/en/mysql-secure-installation.html
Http://dev.mysql.com/doc/refman/5.7/en/default-privileges.html
6. Install additional mysql tools
(6.1) view available Package Names
shell> mysql_secure_installation
(6.2) Installation Package
Shell> sudo yum install package name
For example, install mysql-workbench-community.
shell> sudo yum install mysql-workbench-community
7. Upgrade mysql
(7.1) edit/etc/yum. repos. d/mysql-community.repo
(7.2) execute update
shell> sudo yum update mysql-server
Or use the following command to update all packages:
shell> sudo yum update
8. centos7 uses the mariadb database instead of mysql by default. First, uninstall the mariadb package.
(8.1) query the maridb package command
shell> sudo rpm -qa | grep -i mariadb
(8.2) Delete
Shell> sudo rpm-e related package name