Rotten mud: mysql5.5 database cmake source code compilation and installation, mysql5.5cmake

Source: Internet
Author: User

Rotten mud: mysql5.5 database cmake source code compilation and installation, mysql5.5cmake

This article was sponsored by Xiuyi linfeng and first launched in the dark world.

I have also written an article on mysql5.0 source code compilation, which is "Dirty: mysql5.0 database source code compilation and installation". However, since MySQL 5.5, the cmake compilation tool has been used.

Therefore, this article mainly explains how to compile and install mysql5.5 and later versions through cmkae.

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

Cat/etc/system-release

Uname-

Before installing the mysql database, you must first create a mysql user 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 that useradd-M-s/sbin/nologin mysql, the-M parameter in this command, which means that when creating a user, you do not create the corresponding home directory for the user, -s/sbin/nologin indicates that the user cannot log on to the system.

After creating the package, you can download the package of mysql5.5 by running the following command:

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

After mysql5.5 is downloaded, we now start to install the required software package for mysql compilation and installation. Run the following command:

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

Note that the cmkae software package must be installed. Otherwise, mysql5.5 cannot be installed.

The definition of cmkae is as follows:

Cmake is a cross-platform installation (Compilation) tool. You can use simple statements to describe the installation (compilation process) of all platforms ). It can output a variety of makefiles or project files and test the C ++ features supported by the compiler, similar to automake in UNIX. Cmakelists.txt is the only available file for cmake.

Cmake does not directly construct the final software, but generates standard construction files (such as Unix makefile or Windows Visual C ++ projects/workspaces), which are then used in a general construction mode.

After all the above software is installed, decompress mysql5.5 and run the following command:

Tar-xvf mysql-5.5.39.tar.gz

View the extracted document as follows:

Note the cmkae directory marked in the figure. This is the important file we need to install.

Start to install mysql5.5. Use the following command to configure mysql5.5as follows:

Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql

Note that this is different from the previous version of mysql5.5 source code. Previous versions use./configure for configuration.

After the configuration is complete, compile mysql5.5 and use the make command. As follows:

Make

After compilation, install mysql5.5 and run the make install command. As follows:

Make install

After the installation is complete, we cannot start the mysql database now, and some configuration is required.

To modify the user and User Group of the mysql running directory, run the following command:

Chown mysql: mysql-R/usr/local/mysql/

Why do we need to modify it? This is because mysql is used when mysql is running.

After the user of the mysql running directory is modified, We need to initialize the mysql database.

Run the following command in the installation directory of mysql5.5:

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

Note that -- user = mysql in the command line indicates the user used to run the mysql database, and -- basedir =/usr/local/mysql indicates the location where the mysql database is installed, -- datadir =/usr/local/mysql/data indicates the data file storage location of the mysql database.

When you execute this command, the system will prompt that you have insufficient permissions. As follows:

View the permissions of the mysql_install_db file as follows:

Ll scripts/mysql_install_db

In addition, we can see that the mysql_install_db file does not have the executable permission at all.

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

Chmod a + x./scripts/mysql_install_db

After the permission is configured, run the preceding command again. As follows:

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

After the database Initialization is complete, we have two more work to do. First, configure the mysql configuration file my. cnf. Second, configure the mysql Startup File.

You can enter the content of the my. cnf file, or modify it based on the template provided in the mysql Installation File.

The template file is the my-medium.cnf under the support-files directory and several other 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

After copying the file, view the my. cnf file again as follows:

Cat/etc/my. cnf | grep-v ^ # | grep-v ^ $

In this command, grep-v ^ # indicates that the line starting with # is not displayed, and grep-v ^ $ indicates that the line starting with # is not displayed.

After configuring the my. cnf file, copy the mysql. server File under the support-files directory to/etc/init. d/and rename it mysqld. Mysqld is the file that starts mysql as a service. As follows:

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

We can find that the mysqld file has no execution permission. Now we need to grant the execution permission to it as follows:

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

After all the preceding modifications and configurations are complete, we can start the MySQL database.

Start and view as follows:

/Etc/init. d/mysqld start

Ps aux | grep mysqld

Netstat-tunlp | grep 3306

We can see that the mysql database has been successfully started.

Log on to the mysql database and run the mysql command. We need to add the/usr/local/mysql/bin/path to the environment variable of the system. Otherwise, the mysql command cannot be used. As follows:

Now add the/usr/local/mysql/bin/path to the environment variable of the system, as shown below:

Echo $ PATH

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

Source/etc/profile

Mysql-u root-p

Through, we can see that the mysql command can be used normally.

The installation of mysql5.5 cmake source code is complete.


When Mysql5530 fails to be compiled using Cmake, the following error is returned:

The installation version is incorrect. Select the Source Code under MySQL Community Server.
If the system does not send a URL, re-click it.
 
An error occurred while compiling mysql55 with cmake: Unknown CMake command "CHECK_LIBRARY_EXISTS"

./Configure ---- prefix =/cmake
You still use -- prefix to specify the custom directory. In addition, XXOO says that this specified directory can run ......
Ah ......

1. make uninstall, but not all of them support
2. export PATH =/cmake/bin: $ PATH
3. I remember that bootstrap is a control script of a project management program used to generate a compilation environment. Configure seems to be generated by him, but generally, after a software project is released, it will generate an environment that is sufficient for use, so it is not necessary.

About cmake, I want to say that your system does not have to use make?


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.