CentOS6.x compile and install LAMP (3): compile and install mysql5.25

Source: Internet
Author: User
Tags chmod mysql version iptables

Required software source package:

Cmake-2.8.8.tar.gz
Mysql-5.5.25.tar.gz

1. Install cmake

MySQL 5.5 and later versions have been replaced by the cmake tool./configure compilation and configuration method.

Therefore, we must first compile and install the cmake tool in the system source code.

The code is as follows: Copy code

# Install the required dependency package

Yum-y install ntp vim-enhanced gcc-c ++ flex bison autoconf automake bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel xlibpm-devel gettext-devel pam-devel libtool-ltdl openssl-devel fontconfig-devel libxml2-devel curl-devel libicu-devel libmcrypt-devel libmhash-devel

# Compile and install

Cd/usr/local/src/cmake-2.8.8

./Configure

Make & make install

2. Compile, install, and configure MySQL

The code is as follows: Copy code

# Switch to mysql extract Directory

Cd/usr/local/src/mysql-5.5.25

# Create a directory

Mkdir-pv/usr/local/mysql/data

# Create a mysql user and a mysql Group

Groupadd mysql

2 useradd-g mysql-s/usr/sbin/nologin mysql

# Cmake compilation

Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-plugin =/usr/local/mysql/data-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = export-DWITH_READLINE = 1-DWITH_SSL = system-plugin = 1-DENABLED_LOCAL_INFILE = 1-DDEFAULT_COLLATION = utf8_general_ci-DWITH_MYISAM_STORAGE_ENGINE = 1-DWITH_INNOBASE_STORAGE_ENGINE = 1-DWITH_DEBUG = 0

# Installation

Make & make install

# Copy the configuration file

Cp./support-files/my-medium.cnf/etc/my. cnf

# Set permissions

Chmod + x/usr/local/mysql

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

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

# Configure automatic start upon startup

Cp./support-files/mysql. server/etc/init. d/mysqld

2 chmod + x/etc/init. d/mysqld

3 chkconfig -- add mysqld

4 chkconfig mysqld on

# Add a MySQL soft link to adapt to the init script

Ln-sv/usr/local/mysql/bin/mysql/usr/sbin/mysql

2 ln-sv/usr/local/mysql/bin/mysqladmin/usr/sbin/mysqladmin

3 ln-sv/usr/local/mysql/bin/mysqldump/usr/sbin/mysqldump

# Modifying the configuration file

Vim/etc/my. cnf

# Add in [mysqld:

Datadir =/usr/local/mysql/data

2 log-error =/usr/local/mysql/data/error. log

3 pid-file =/usr/local/mysql/data/mysql. pid

4 user = mysql

5 tmpdir =/tmp

# Save and exit

# Initializing a database

/Usr/local/mysql/scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data

Configure the firewall to enable Port 3306

Vim/etc/sysconfig/iptables

# Add the following rule to Port 3306.

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

# Restarting the firewall

/Etc/init. d/iptables restart # or service iptables restart

Start MySQL

Service mysqld start # or/etc/init. d/mysqld start

Test whether MySQL is started

# Check whether a mysql process exists

Ps-ef | grep mysql

# Check whether the mysql Port exists

Netstat-tnlp | grep 3306

# Test whether the mysql, mysqladmin, and mysqldump commands can be used normally

# Read MySQL version information

Mysqladmin version

MySQL compilation and installation 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.