Linux in the CMake compiler mysql5.5 database Source installation Tutorial

Source: Internet
Author: User
Tags chmod documentation mysql client mysql in windows visual

MySQL has been using the CMake compilation tool since version 5.5, so this article is mainly about how to install mysql5.5 and its later versions through Cmkae compilation.

Note that the environment of this article is centos6.5 64bit.

Cat/etc/system-release

Uname-a

Before installing the MySQL database, we first want to create a new MySQL runtime user MySQL in the system. As follows:

Useradd-m-s/sbin/nologin MySQL

grep mysql/etc/passwd

CAT/ETC/PASSWD |grep MySQL

grep mysql/etc/group

Note Useradd-m-s/sbin/nologin MySQL, the-m parameter in this command, which means that the user is not created with the corresponding home directory when the user is created,-s/sbin/nologin that the user cannot log on to the system.

Once the user is created, we will now download the mysql5.5 package and use the following command:

wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.39.tar.gz

mysql5.5 download is complete, we are now ready to install MySQL compile installation when the required package. Use the following command:

Yum-y install gcc gcc-c++ cmake ncurses-devel libtool zilib-devel

Note that the Cmkae package must be installed or we will not be able to install mysql5.5 below.

Related to the interpretation of Cmkae, Baidu Encyclopedia as follows:

CMake is a Cross-platform installation (compilation) tool that describes the installation (compilation process) of all platforms with simple statements. It can output a wide variety of makefile or project files, and can test the C + + features supported by the compiler, similar to the Automake under UNIX. Just CMake's configuration file is named CmakeLists.txt.

Instead of building the final software directly, CMake produces standard construction files (such as Unix makefile or Windows Visual C + + projects/workspaces), which are then used in general construction.

After all the above software has been installed, we now begin to extract mysql5.5, using the following command:

TAR-XVF mysql-5.5.39.tar.gz

View the extracted documents as follows:

Note The Cmkae directory that is marked in the figure. This is the important document we need to install.

Now start the formal installation of mysql5.5, using the following command to configure mysql5.5. as follows:

Cmake-dcmake_install_prefix=/usr/local/mysql

Note that this is different from the previous version of the mysql5.5 source installation. Previous versions were configured with./configure.

At the same time,-dcmake_install_prefix This parameter is not easy to remember, but there is no need to worry. In fact, the MySQL installation documentation has been given the relevant installation steps. View the Install-source installation documentation. As follows:

Cat Install-source |sed-n ' 5417,5438p '

The purpose of this command is to display the contents of the Install-source file between 5417 and 5438 lines.

Once the configuration is complete, start compiling mysql5.5 and use the Make command. As follows:

Make

When you have finished compiling, start installing mysql5.5 and use the Make install command. As follows:

Make install

After installation, we can not start the MySQL database, we need to do some configuration.

Modify the users and groups of the MySQL running directory, using the following command:

Chown Mysql:mysql-r/usr/local/mysql/

Why do you want to change it? is because MySQL runs when the user is used on MySQL.

MySQL running directory of the user to modify the completed, we also initialize the MySQL database.

Under the mysql5.5 installation directory, execute the following command:

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

Note that the--user=mysql in this command line represents the user used when running the MySQL database,--basedir=/usr/local/mysql says the MySQL database says the location of the installation,--datadir=/usr/local/mysql/ Data represents the location of the MySQL database's datastore.

When you execute this command, you are prompted for insufficient permissions. As follows:

View the related permissions for the mysql_install_db file as follows:

ll scripts/mysql_install_db

And by the image above, we can clearly see that the mysql_install_db file does not have executable permissions at all.

We need to configure executable permissions for the mysql_install_db file as follows:

chmod a+x./scripts/mysql_install_db

Once the permissions have been configured, we execute the above command again. As follows:

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

After the database initialization, we have two more jobs to do. One is to configure the MySQL configuration file my.cnf. The second is to configure the MySQL startup file.

The contents of the My.cnf file can be filled out by ourselves or modified according to the template provided in the MySQL installation file.

The template file is a support-files directory of MY-MEDIUM.CNF, and so on several files. We now take the my-medium.cnf file as an example, we just need to copy the file and rename it to MY.CNF. As follows:

CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF

Once the copy is complete, view the my.cnf file again as follows:

CAT/ETC/MY.CNF |grep-v ^#|grep-v ^$

Note the line at the beginning of grep-v ^ #表示不显示以 # in this command, Grep-v ^$ indicates that the opening line is not displayed with white space.

After the my.cnf file is configured, we will also copy the Mysql.server file under the Support-files directory to/etc/init.d/and rename it to Mysqld. Mysqld is the file that starts MySQL as a service. As follows:

CP Support-files/mysql.server/etc/init.d/mysqld

We can see from the diagram above that the mysqld file does not have permission to execute. We now need to give it permission to do the following:

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

Once all of the above modifications and configuration are complete, we can start the mysql5.5 database.

Start and view the following:

/etc/init.d/mysqld start

PS aux |grep mysqld

NETSTAT-TUNLP |grep 3306

From the above figure, we can see that the MySQL database has been successfully started.

Below we login to the MySQL database to see, to use the MySQL command. We need to add the/usr/local/mysql/bin/path to the system's environment variable, otherwise the MySQL command will not be available. As follows:

Now add the/usr/local/mysql/bin/path to the system's environment variable, as follows:

Echo $PATH

echo path= $PATH:/usr/local/mysql/bin >>/etc/profile

Source/etc/profile

Mysql-u root-p

We can see from the above diagram that the MySQL command is working properly.

To this mysql5.5 cmake source code installation is finished.

If the MySQL client is connected, the MySQL service is slower. We need to include skip-name-resolve in the My.cnf file as follows:

 

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.