Tutorial on MySQL5.6.14 compilation and installation under CentOS 6.4, centosmysql5.6.14

Source: Internet
Author: User

Tutorial on MySQL5.6.14 compilation and installation under CentOS 6.4, centosmysql5.6.14

Overview:

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

Body:

1. 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 you use the preceding command to delete a file, the system prompts other dependent files, you can use this command to forcibly delete it.

Ii. Install MySQL

Install the package required for compiling code

yum -y install make gcc-c++ cmake bison-devel ncurses-devel

Download MySQL 5.6.14

wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.14.tar.gztar xvf mysql-5.6.14.tar.gzcd mysql-5.6.14

Compile and install

cmake \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/usr/local/mysql/data \-DSYSCONFDIR=/etc \-DWITH_MYISAM_STORAGE_ENGINE=1 \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_MEMORY_STORAGE_ENGINE=1 \-DWITH_READLINE=1 \-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \-DMYSQL_TCP_PORT=3306 \-DENABLED_LOCAL_INFILE=1 \-DWITH_PARTITION_STORAGE_ENGINE=1 \-DEXTRA_CHARSETS=all \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_cimake && make install

For compilation parameters, see http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html.

The entire process takes about 30 minutes ...... Long wait

3. Configure MySQL

Set permissions

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

Create if no

groupadd mysqluseradd -g mysql mysql

Modify/usr/local/mysql Permissions

chown -R mysql:mysql /usr/local/mysql

Modify/usr/local/mysql Permissions

Initialize Configuration

Enter the installation path

cd /usr/local/mysql

Go to the installation path, execute the initialization configuration script, and 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 the CentOS 6.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.

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/mysqlchkconfig mysql onservice mysql start -- start MySQL

Configure the user

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:$PATHexport 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('123456');

To set remote access for the root user, run

Mysql> grant all privileges on *. * TO 'root' @ '1970. 16.% 'identified by 'Password' with grant option;

When the red password is used for remote access, the root user password may be different from the local password.

Configure 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

OK. All configurations are complete. You can access your MySQL instance ~

Add in December 02, 2014:

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

Highlights: mysql installation tutorials for different versions mysql5.7 installation tutorials for various versions mysql5.6 installation tutorials

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.