Compile and install MySQL in CentOS 7

Source: Internet
Author: User

Compile and install MySQL in CentOS 7

Hardware environment: Dell PowerEdge R710

System: CentOS 7*86_64

1) download the mysql-5.1.57 source package (click I download), put in/usr/local/src. Mysql-5.1.57 source code compilation installation steps are as follows.

Since the servers are installed with minimal installation, you need to install the gcc-c ++ and other basic library files. The command is as follows:

[Html] view plaincopy
  1. Yuminstallgcc
  2. Yuminstallgcc-c ++
  3. Yumlist | grepncurses
  4. Yum-yinstallncurses-devel
  5. Yuminstallncurses-devel

Generate mysql users and user groups using the following command:

[Html] view plaincopy
  1. Groupaddmysql
  2. Useradd-gmysqlmysql

Source code compilation to install the mysql-5.1.57, the command is as follows:

[Html] view plaincopy
  1. Cd/usr/local/src
  2. Tarzxvfmysql-5.1.57.tar.gz
  3. Cdmysql-5.1.57
  4. ./Configure -- prefix =/usr/local/mysql
  5. Make & makeinstall & cd ../

2) Configure permissions for mysql and set the data installation path of mysql to/data/mysql. Configure mysql as the service startup status as follows:

[Html] view plaincopy
  1. Cd/usr/local/mysql
  2. Cp/usr/local/mysql/share/mysql/my-huge.cnf/etc/my. cnf
  3. Cp/usr/local/mysql/share/mysql. server/etc/init. d/mysqld
  4. Chown-Rmysql: mysql/usr/local/mysql/
  5. Mkdir-p/data/mysql
Here only the system comes with the my-huge.cnf as the MySQL database configuration file, later according to the MySQL status of the operating status for tuning.

3) modify the [mysqld] item of/etc/my. cnf under the MySQL server and add the data storage path for mysql runtime under it, as shown below:

[Html] view plaincopy
  1. Datadir =/data/mysql
4) run the following command on the server to generate the mysql initialization file and initial database under/data/MySQL:

[Html] view plaincopy
  1. /Usr/local/mysql/bin/mysql_install_db -- user = mysql -- datadir =/data/mysql
5) Now you can start the MySQL service as a service, as shown below:

[Html] view plaincopy
  1. Servicemysqldstart

We will configure it as the self-starting status. The command is as follows:

[Html] view plaincopy
  1. Chkconfigmysqldon

After the configuration is complete, run the following command:

[Html] view plaincopy
  1. Chkconfig -- listmysqld

The result is as follows, indicating that the above settings are successful:

[Html] view plaincopy
  1. Mysqld0: off 1: off 2: open 3: Open 4: Open 5: Open 6: Off

6) add mysql environment variables in/usr/bin as follows:

[Html] view plaincopy
  1. Ln-s/usr/local/mysql/bin/mysql/usr/bin

7) disable the system firewall as follows:

[Html] view plaincopy
  1. Systemctlstopfirewalld

8) modify the password of the root user and allow remote access, as shown below:

[Html] view plaincopy
  1. Usemysql;
  2. Updateusersetpassword = password ("root") whereuser = "root ";
  3. GRANTALLPRIVILEGESON *. * TO 'root' @ '%' IDENTIFIEDBY 'root' WITHGRANTOPTION;
  4. Flushprivileges;

At this point, the steps for compiling and installing MySQL under CentOS 7 are complete.

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.