Centos uses yum to install mysql and centosyummysql

Source: Internet
Author: User
Tags yum repolist

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.