Install MySQL 5.6.26 through source code in CentOS6

Source: Internet
Author: User
Tags install perl

Install MySQL 5.6.26 through source code in CentOS6

MySQL 5.1 installed through yum in CentOS6 is old, so I want to install the later version 5.6.26 through the source code.

I. Uninstall the old version

Run the following command to check whether MySQL Server is installed.

Rpm-qa | grep mysql

If yes, run the following command to uninstall it:

Rpm-e mysql // normal deletion Mode
Rpm-e -- nodeps mysql // strong deletion mode. If the above command is used to delete other dependent files, you can use this command to forcibly delete them.

Ii. Install the tools required for MySQL Compilation

Install g ++ and gdb

Yum install gcc-c ++
Yum install gdb

Install cmake

Yum install cmake

Install ncurses

Yum install ncurses-devel

Install bison

Yum install bison-devel

Refer to http://dev.mysql.com/doc/refman/5.6/en/source-installation.html for tool descriptions for compiling Dependencies

Iii. Install MySQL

1) download MySQL 5.6.26 at the following two links:

Download with wget, as shown below:

Https://downloads.mariadb.com/archives/mysql-5.6/mysql-5.6.26.tar.gz

What if I want to download another version? (Remove the version numbers in the red section below to find the installation files of all the current versions)

Https://downloads.mariadb.com/archives/mysql-5.6

Tar xvf mysql-5.6.26.tar.gz
Cd mysql-5.6.26

2) Compile and install (the following path can be modified)

Cmake \
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DMYSQL_DATADIR =/usr/local/mysql/data \
-DSYSCONFDIR =/etc \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_PARTITION_STORAGE_ENGINE = 1 \
-DMYSQL_UNIX_ADDR =/tmp/mysql. sock \
-DMYSQL_TCP_PORT = 3306 \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci

Make

After compilation, you can install

Make install

For the translated parameters, see http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html

The compilation process takes about 15 minutes. After compilation and installation are complete, you can check the result.

Ll/usr/local/mysql

4. Configure MySQL

1) configure the user

Run the following command to check whether mysql users and user groups exist:

Cat/etc/passwd view User List
Cat/etc/group view User group list

Confirm the creation result

Id mysql

Modify/usr/local/mysql Directory Permissions

Chown-R mysql: mysql/usr/local/mysql

2) initialize the configuration

Install the perl required to run the MySQL test script

Yum install perl

Enter the installation path

Cd/usr/local/mysql

Execute the initialization configuration script to create the database and table that comes with the system.

Scripts/mysql_install_db -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data -- user = mysql

Note: when starting the MySQL service, I will be searched in certain order. cnf, which is first found in the/etc directory. If no cnf is found, "$ basedir/my. cnf ", in this example/usr/local/mysql/my. cnf, which is the default location of the new MySQL configuration file!

Note: After the minimal installation of CentOS6.4 operating system is complete, a my. cnf, You need to rename this file to another name, such as:/etc/my. cnf. bak. Otherwise, the file will interfere with the correct configuration of MySQL installed by source code, resulting in startup failure.

After updating the system using "yum update", you need to check whether there will be an extra my. cnf in The/etc directory. If there are more, rename it to something else. Otherwise, MySQL will use this configuration file to start, which may cause problems such as failure to start normally.

3) Start MySQL

Add a service, copy the service script to the init. d directory, and set startup

Cp support-files/mysql. server/etc/init. d/mysql
Chkconfig mysql on
Service mysql start -- start MySQL

4) configure the MySQL account password

After MySQL is started successfully, the root user has no password by default. We need to set the root password.

Before setting, we need to set the PATH first, or we cannot directly call mysql

Modify the/etc/profile file and add

PATH =/usr/local/mysql/bin: $ PATH
Export PATH

Close the file and run the following command to make the configuration take effect immediately

Source/etc/profile

Now, we can directly enter mysql in the terminal to enter the mysql environment.

Run the following command to change the root password:

Mysql-uroot
Mysql> set password = PASSWORD ('abcd @ 808080 ');

To set remote access for the root user, run

Grant all privileges on *. * to 'root' @ '%' identified by 'abcd @ 100' with grant option;
Flush privileges;

The password for remote access can be different from that for local access.

5) configure the firewall

Port 3306 of the firewall is disabled by default. To access the firewall remotely, you must enable this port.

Open/etc/sysconfig/iptables

In "-a input-m state -- state NEW-m tcp-p-dport 22-j ACCEPT", add:

-A input-m state -- state NEW-m tcp-p-dport 3306-j ACCEPT

Save and close the file. Run the following command in the terminal to refresh the Firewall Configuration:

Service iptables restart

After all the configurations are complete, you can access MySQL.

Then add:

In CentOS 7, Firewalld is used as the firewall by default. Therefore, after iptables is modified, it does not work after the system is restarted.

The method for adding a port to Firewalld is as follows:

Firewall-cmd -- zone = public -- add-port = 3306/tcp -- permanent

Firewall-cmd -- reload

Related Article

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.