Three common methods for installing MySQL _ MySQL

Source: Internet
Author: User
MySQL is an open-source small-scale associated database management system, which is widely used in small and medium websites on the Internet. Next, I will share with you the following three methods for installing MySQL. For more information, see the following Directory.

There are three common ways to install MySQL:

Rpm Package format

Common binary format

Source code compilation

1. rpm Package format

(1) provided by the operating system Publisher

(2) officially provided by MySQL (version updates fix more common bugs) www.mysql.com/downloads

Introduction to the rpm Package type in MySQL:

MySQL-client component
MySQL-debuginfo
MySQL-devel wants to compile and install MySQL-dependent components such as PHP for MySQL.
Embedded MySQL-embedded MySQL version
MySQL-server shared library
MySQL-shared library
MySQL-shared-dompat to be compatible with shared libraries of earlier versions
MySQL-test MySQL test component (online processing function)

Installation method:

First, you can download the rpm Package of the corresponding version from the installation disc or to the mysql website as follows:

MySQL-server-community-5.5.28-1.rhel5.i386.rpm
MySQL-client-community-5.5.28-1.rhel5.i386.rpm

Then we can use the rpm command for installation:

Rpm-ivh MySQL-server-community-5.5.28-1.rhel5.i386.rpm
Rpm-ivh MySQL-client-community-5.5.28-1.rhel5.i386.rpm

Add:

-H use the symbol # display the installation progress
-V: Report operations in each step

2. general binary package

(1) create a user to run the process securely:

 groupadd -r mysql  useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql  chown -R mysql:mysql /mydata/data 

(2) install and initialize the mysql-5.5.28

Bytes

tar xf mysql-5.5.28-linux2.6-i686.tar.gz -C /usr/local  cd /usr/local/  ln -sv mysql-5.5.28-linux2.6-i686 mysql  cd mysql  chown -R mysql:mysql .  scripts/mysql_install_db --user=mysql --datadir=/mydata/data  chown -R root . 

(3) provide the primary configuration file for mysql:

 cd /usr/local/mysql  cp support-files/my-large.cnf /etc/my.cnf 

(4) modify the configuration file:

Modify the value of thread_concurrency in this file to multiply the number of your CPUs by 2. for example, use the following line here:

Thread_concurrency = 2

You also need to add the following lines to specify the storage location of mysql data files:

Datadir =/mydata/data

(5) provide the sysv service script for mysql:

cd /usr/local/mysql  cp support-files/mysql.server /etc/rc.d/init.d/mysqld 

(6) add to service list:

 chkconfig --add mysqld  chkconfig mysqld on 

(7) then you can start the service test.

service mysqld start

3. source code compilation

(The installation and compilation methods have changed a bit, and the configuration process has not changed much. Therefore, the steps are not described in detail later)
To compile and install the source code on the 5.0 Red Hat system, MySQL must use a cross-platform compiler cmake.

Therefore:

(1) install cmake

Make is required for cmake installation.

Tar xf cmake-...tar.gz cd cmake-.../bootstrap use this script to detect the compilation environment make install

(2) compile and install mysql-5.5.28

Using cmake to compile mysql-5.5.28, the option method has changed a brief introduction...

Cmake specifies the compilation option in a different way than make. the implementation method is as follows:

Cmake.

Cmake.-LH or ccmake. find available options

This option is often used to specify the installation path of the installation file:

-DCMAKE_INSTALL_PREFIX =/usr/local/mysql specifies the installation path
-DMYSQL_DATADIR =/data/mysql data Installation Path
-DSYSCONFDIR =/etc configuration file installation path

Because MySQL supports many storage engines, the default compiled storage engines include csv, myisam, myisammrg, and heap. To install other storage engines, you can use the following compilation options:

-DWITH_INNOBASE_STORAGE_ENGINE = 1 install the INNOBASE storage engine
-DWITH_ARCHIVE_STORAGE_ENGINE = 1 install the ARCHIVE storage engine
-DWITH_BLACKHOLE_STORAGE_ENGINE = 1 install the BLACKHOLE storage engine
-DWITH_FEDERATED_STORAGE_ENGINE = 1 install the FEDERATED Storage Engine

To explicitly specify not to compile a storage engine, you can use the following options:

-DWITHOUT _ _ STORAGE_ENGINE = 1

For example:

-DWITHOUT_EXAMPLE_STORAGE_ENGINE = 1: The EXAMPLE storage engine is not enabled or compiled.
-DWITHOUT_FEDERATED_STORAGE_ENGINE = 1
-DWITHOUT_PARTITION_STORAGE_ENGINE = 1

If you want to compile it into other functions, such as SSL, you can use the following options to compile a database or not use a database:

-DWITH_READLINE = 1
-DWITH_SSL = system: Use the built-in SSL library on the system.
-DWITH_ZLIB = system
-DWITH_LIBWRAP = 0

Other common options:

-DMYSQL_TCP_PORT = 3306 set the default port
-DMYSQL_UNIX_ADDR =/tmp/mysql. sock MySQL socket location for inter-process communication
-DENABLED_LOCAL_INFILE = 1 whether to start the local LOCAL_INFILE
-DEXTRA_CHARSETS = all: additional character sets supported
-DDEFAULT_CHARSET = utf8 default character set
-DDEFAULT_COLLATION = utf8_general_ci default character set sorting rule
-DWITH_DEBUG = 0: whether to enable the DEBUG function
-DENABLE_PROFILING = 1 whether to enable the performance analysis function

To clear the files generated by the previous compilation, run the following command:

Make clean
Rm CMakeCache.txt

Compile and install

Tar xf mysql-5.5.28.tar.gz cd mysql-5.5.28 groupadd-r mysql useradd-g-r mysql mkdir-pv/data/mydata chown-R mysql: mysql/data/mydata cmake. -DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_DATADIR =/data/mydata-DSYSCONFDIR =/etc-region = 1-region = 1-region = 1-DWITH_READLINE = 1-DWITH_SSL = system-DWITH_ZLIB = system-DWITH_LIBWRAP = 0-DMYSQL_UNIX_ADDR =/tmp/mysql. sock-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci make install cd/usr/local/mysql chown-R: mysql. change the group scripts/mysql_install_db -- user = mysql -- datadir =/data/mydata/specify the data storage location cp support-files/my-large.cnf/etc/my. create a configuration file using cnf

Edit configuration file

Vim/etc/my. cnf

Add the following lines to specify the storage location of mysql data files:

Datadir =/mydata/data

Create execution scripts and start services

Cp support-files/mysql. server/etc/rc. d/init. d/mysqld copy script chmod + x/etc/rc. d/init. d/mysqld execution permission chkconfig-add mysql add to service list mysqld start service bin/mysql start mysql

The above is the three common methods for installing MySQL.

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.