"MySQL" source code compilation install and configure MySQL 5.5.32 (Single instance)

Source: Internet
Author: User

"Requirements description"

In the CentOS environment, the MySQL5.5.32 database of "single instance" is installed and configured by compiling the source code.

The installation directory for MySQL is:/application/mysql-5.5.32

The installation directory for MySQL data files is:/application/mysql-5.5.32/data

The default character encoding for MySQL is: UTF8

"Environment Parameters"

vmware:10.0.1

Host:win7

Db:mysql 5.5.32

Compilation tool: Cmake-2.8.8.tar.gz

Other dependencies: ncurses-devel-5.7-3.20090208.el6.x86_64.rpm

Client:centos 6.5 x86_64,i686, minimized installation (Minimal).

When you install a custom component package,

(1) The Base system installs only base,compatibility libraries and debugging Tools.

(2) Development only installed development Tools.

"Software Download"

(1) Mysql:

http://downloads.mysql.com/archives/community/?tpl=files&os=src&version=5.5.33

Select "Generic Linux (Architecture independent), compressed TAR Archive" To download this version.

(2) Download CMake

CMake Baidu Cloud Disk Connection: HTTP://PAN.BAIDU.COM/S/1DDAWXSL

CMake is a cross-platform installation (compilation) tool that can be used to describe the installation of all platforms (the compilation process) with simple statements. He is able to output a variety of Makefile or project files that can test the C + + features supported by the compiler, similar to the Automake under UNIX. Only the CMake configuration file is named CmakeLists.txt.

(3) Download Ncurse-devel dependency Package

NCURSES-DEVEL-5.7-3.20090208.EL6.X86_64.RPM's Baidu Cloud disk share:

Http://pan.baidu.com/s/1pJpDRCJ

"Concrete Steps"

1. Viewing the system environment

[Email protected] ~]# cat/etc/redhat-release
CentOS Release 6.5 (Final)
[Email protected] ~]#
[Email protected] ~]#
[Email protected] ~]# uname-r
2.6.32-431.el6.x86_64
[Email protected] ~]#

2. Install related software packages
(1) Configuring, compiling, and installing the CMake compilation tool
① in current directory, unzip cmake-2.8.8.tar.gz
# TAR–ZXVF Cmake-2.8.8.tar.gz

② switch from the current directory to the cmake-2.8.8 directory,
# CD cmake-2.8.8

③ executes the command "#./configure" To configure the CMake tool.
#./configure

④ Compiling CMake Tools
After the CMake configuration is complete, you will be prompted as follows:

After that, execute the gmake command to compile the work,

# Gmake

⑤ checks whether the previous "Gmake" command was successful.
[[email protected] cmake-2.8.8]# echo $?
0
Explanation: "echo $?" Represents the result of displaying the previous command execution, and if the return value is 0, the previous command executed successfully.

⑥ Installing the CMake tool
# gmake Install

⑦ when the installation is complete, return to the previous level directory
# CD:

(2) Install dependent packages
1) Install Ncurse-devel dependency Package
Yum Install Ncurse-devel-y

If the Yun cannot be installed, then go online to download the "ncurses-devel-5.7-3.20090208.el6.x86_64.rpm" RPM package.

NCURSES-DEVEL-5.7-3.20090208.EL6.X86_64.RPM's Baidu Cloud disk share: Http://pan.baidu.com/s/1pJpDRCJ

3. Create MySQL user and MySQL user group
[[email protected]/]# Groupadd MySQL
[[email protected]/]# useradd mysql-s/sbin/nologin-m-G MySQL
Command Description:
① "–s/sbin/nologin": Indicates that the user is forbidden to log on and to enhance security.
② "–g MySQL": Specifies that it belongs to the MySQL group.
③ "–M": indicates that the user home directory is not created.

Check the created user
[Email protected] ~]# tail-1/etc/passwd
Mysql:x:500:500::/home/mysql:/sbin/nologin

Note: The parameter is "number 1", not the letter "L".

4. Unzip, compile and install MySQL software (important)
(0) Create a MySQL installation directory
[Email protected]/]# mkdir–p/application/mysql-5.5.32

(1) in the temp directory, unzip the source bundle: mysql-5.5.32.tar.gz
# TAR–ZXVF mysql-5.5.32./

(2) Compiling MySQL
After switching to the extracted mysql-5.5.32 source directory, execute the following cmake command to compile (important)
Note 01: The following CMake commands can be reused.
Note 02: The directory "/application/mysql-5.5.32" is a user-defined "MySQL installation directory".
Note 03: When compiling, there are a number of configurable options, which can be found at the end of the appendix or official documentation.
Official document mysql5.1_chs.chm,2.8. Install MySQL using the source distribution version

The following commands are important and can be reused.

CMake. -dcmake_install_prefix=/application/mysql-5.5.32 -dmysql_datadir=/application/mysql-5.5.32/data -dmysql_unix_addr=/application/mysql-5.5.32/tmp/mysql.sock-ddefault_charset=utf8-ddefault_collation=utf8_ General_ci-dextra_charset=gbk,gb2312,utf8,ascii-denabled_local_infile=on-dwith_innobase_storage_engine=1-dwith _federated_storage_engine=1-dwith_blackhole_storage_engine=1-dwithout_exampl_estorage_engine=1-dwithout_ Partition_estorage_engine=1-dwith_fast_mutexes=1-dwith_zlib=bundled-denabled_local_infile=1-dwith_readline=1- Dwith_enbedded_server=1-dwith_debug=0

Once the compilation is complete, you should be prompted as follows:

--Build files has been written to:/root/zj-tools/mysql-5.5.32
[Email protected] mysql-5.5.32]#

(3) Installing MySQL

# Make && make install

If there is no error during the installation process, the installation of the MySQL software is completed. After the installation is complete, a "Application" folder appears in the root directory, as shown in.

(4) Create a link file
# ln–s/application/mysql-5.5.32//application/mysql


(5) Reminders of matters
At this point, the completion of the way to compile the source of the installation of MySQL, after the installation of MySQL database, but also to make a variety of configurations, the next need to configure MySQL.
to install the multi-instance MySQL database, the following "Configure, initialize MySQL data files and services for single instance" notes can be skipped .

5, configuration, initialization of single-instance MySQL data files and services (single instance, important)

5.1. View the default template configuration file
In the MySql-5.5.32 source installation directory has a folder "Support-files", MySQL commonly used various template configuration files are stored in this directory.

[Email protected] mysql-5.5.32]# pwd
/root/zj-tools/mysql-5.5.32
[Email protected] mysql-5.5.32]# CD support-files/
[[email protected] support-files]# ls
Binary-configure Magic mysql-log-rotate.sh
binary-configure.sh Makefile MYSQL.M4
Build-tags my-huge.cnf mysql-multi.server.sh
Cmakefiles my-huge.cnf.sh Mysql.server
Cmake_install.cmake my-innodb-heavy-4g.cnf mysql.server.sh
CMakeLists.txt my-innodb-heavy-4g.cnf.sh mysql.server-sys5.sh
Compiler_warnings.supp my-large.cnf Mysql-shared-compat.spec
Config.huge.ini my-large.cnf.sh mysql-shared-compat.spec.sh
config.huge.ini.sh my-medium.cnf Mysql.spec
Config.medium.ini my-medium.cnf.sh mysql.spec.sh
config.medium.ini.sh my-small.cnf Ndb-config-2-node.ini
Config.small.ini my-small.cnf.sh ndb-config-2-node.ini.sh
config.small.ini.sh Mysql.5.5.32.spec Plugins.files
Ctesttestfile.cmake Mysqld_multi.server Rhel4-selinux
DTrace mysqld_multi.server.sh
MacOSX Mysql-log-rotate
[Email protected] support-files]#

5.2. Select configuration file

Test environment Select small, production environment can be based on hardware selection, for example: MY-INNODB-HEAVY-4G.CNF
The following command copies the configuration files from the MySQL source directory to the "/etc" directory.

[email protected] support-files]# CP my-small.cnf/etc/my.cnf
Cp:overwrite '/etc/my.cnf '? Y
[Email protected] support-files]#

5.3. Configure Environment variables

# echo ' Export path=/application/mysql/bin: $PATH ' >>/etc/profile
# tail-l/etc/profile
# Source/etc/profile
# echo $PATH

Note here:the "/application/mysql/bin" path and the "$PATH" sequencing issue.
To put "/application/mysql/bin" in front of "$PATH", so that when using MySQL-related commands, you will first look for the compiled version of MySQL command.
Because, in the future production system, there may already exist in the Yum or RPM installation of MySQL, so when using the MySQL command such as Mysqldump, will look for the existing MySQL command.
Even a client installed with Yum or RPM will be connected to the "compiled version" of the MySQL server, causing the donkey's head to be wrong with the horse's mouth.

Fault case:
The tricky error case that occurs because the "/application/mysql/bin" path is placed behind "$PATH":
http://oldboy.blog.51cto.com/2561410/1122867

5.4. Initialize the data file (error-prone steps)
# Mkdir–p/application/mysql/data
Create the MySQL data file directory, if you have created it during the installation of the MySQL software, you do not need to create the directory.

Modify the user and user groups of the directory where the data files reside
# Chown–r Mysql:mysql/application/mysql/data

Adjust/tmp permissions, otherwise the initialization will be wrong.
# Chmod–r 1777/tmp

To install the MySQL database file, note the command path:
MySQL init script
[Email protected] scripts]#/mysql_install_db--basedir=/application/mysql--datadir=/application/mysql/data-- User=mysql

Special NOTE: If you use mysql5.0,5.1, omitting the specified DataDir will make an error.
The following are some of the self-contained information of MySQL after initial success, including setting up and modifying MySQL user passwords.

1Warning:the Host'Centos65-mini'Could not being looked up with Resolveip.2This probably means that your libc libraries is not -%compatible3 With this binary MySQL version. The MySQL daemon, mysqld, should work4 normally with the exception that host name resolving won't work.5 This means, should use IP addresses instead of hostnames6When specifying MySQL privileges!7 Installing MySQL system tables ...8 OK9 Filling Help Tables ...Ten OK One  ATo start mysqld at boot TimeYou has to copy -Support-files/mysql.server to the right place forYour system -  theREMEMBER to SET A PASSWORD for the MySQL root USER! -To DoSo, start the server, Thenissue the following commands: -  -/application/mysql/bin/mysqladmin-u Root Password'New-password' +/application/mysql/bin/mysqladmin-u root-h centos65-mini Password'New-passwor D' -  + Alternatively you can run: A/application/mysql/bin/mysql_secure_installation at  - whichWould also give you the option of removing the test - databases and anonymous user created by default. this is -Strongly recommended forproduction servers. -  -See the manual for  Moreinstructions. in  - You can start the MySQL daemon with: toCd/application/mysql; /application/mysql/bin/mysqld_safe & +  -You can test the MySQL daemon with mysql-test-run.pl theCd/application/mysql/mysql-test;Perlmysql-test-run.pl *  $Problems with The/application/mysql/scripts/mysqlbug script!Panax Notoginseng  -[Email protected] scripts]#

Expand
"WARNING: The host ' Centos65-mini ' could not being looked up with RESOLVEIP."
This warning message does not affect the functionality of MySQL, however, you can remove the warning by following the settings below.

Cause: Host name and IP address mapping issues.
Solution: Vim hosts, add the host name of this machine to the file.

5.5. Initialize and configure the MySQL service mysqld
(1) Configure MySQL service mysqld
Enter the folder "Support-files" in the MySql-5.5.32 source installation directory and copy the "Mysql.server" to the Directory "/etc/init.d/mysqld".
[email protected] support-files]# CP mysql.server/etc/init.d/mysqld
[Email protected] support-files]#
[Email protected] support-files]# chmod +x/etc/init.d/mysqld
[Email protected] support-files]#

(2) Start the MySQL server
[[email protected] support-files]#/etc/init.d/mysqld start
Starting MySQL. success!
[Email protected] support-files]#

(3) Verify that the MySQL server is successfully started:
[Email protected] support-files]# Netstat-lntup | grep 3306
TCP 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 36586/mysqld
[Email protected] support-files]#

5.6. Set user name and password, and log in to MySQL server
(1) Set user name and password for MySQL data
[Email protected] support-files]#/application/mysql/bin/mysqladmin-u root password ' new-password '
[[email protected] support-files]#/application/mysql/bin/mysqladmin-u root-h centos65-mini password ' new-passwor d '

(2) Log on to the MySQL database server
[Email protected] support-files]# Mysql-uroot-pnew-password

At this point, the basic configuration of MySQL is complete.

"MySQL" source code compilation install and configure MySQL 5.5.32 (Single instance)

Related Article

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.