Compile and install MySQL5.6.16 under CentOS6.4

Source: Internet
Author: User
Overview: Install later version 5.6.16 through source code in centos. Body: 1: uninstall the old version and run the following command to check whether MySQLServerrpm-qa is installed. | if grepmysql is installed, run the following command to uninstall rpm-emysql normal deletion mode: rpm-e -- nodepsmysql strong deletion mode, if you are using

Overview: Install later version 5.6.16 through source code in CentOS 6.4. Body: 1: uninstall the old version and run the following command to check whether MySQL Server rpm-qa is installed | if grep mysql is installed, run the following command to uninstall rpm-e mysql // normal deletion mode rpm-e -- nodeps mysql // strong deletion mode, if you are using

Overview:

Install later version 5.6.16 through source code in CentOS 6.4.

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 the packages required for installing and compiling MySQL code
yum -y install make gcc-c++ cmake bison-devel  ncurses-devel
Download MySQL 5.6.16
wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.16.tar.gz
tar xvf mysql-5.6.16.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

Iii. Configure MySQL to 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 completed, a my. cnf, You need to rename this file to another name, such as:/etc/my. cnf. bak, no, the file will interfere with the correct configuration of MySQL installed in the source code, resulting in failure to start.

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, you can directly enter mysql in the terminal to enter the mysql environment (enter mysql-u root-p in the terminal)

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'@'172.16.%' IDENTIFIED BY 'password' WITH GRANT OPTION;
'1970. 16.% 'indicates an accessible IP segment. If all IP addresses are allowed, they can be written as' %'

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 tcp -- dport 22-j ACCEPT", add:

-A INPUT m state --state NEW -m tcp -p tcp --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 ~

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.