Linux/redhat source code compilation Installation mysql5.5 Tutorial

Source: Internet
Author: User
Tags curl openssl openssl version socket file permissions automake

One, the source code compiles installs the mysql5.5.2

Operating system: Redhat Enterprise Linux 6.2

1. Create users, directories, and Modify permissions

# mkdir-p/usr/local/mysql/data
# Groupadd MySQL
# useradd-g MySQL MySQL
# Chown-r mysql.mysql/usr/local/mysql/data/

2. Installation of the required related library files

# yum install-y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* cm Ake

3. Decompression mysql-5.5.27.tar.gz

# cd/home/software/
# TAR-ZXVF Mysql-5.5.27.tar.gz

4. Compile and install

# CD mysql-5.5.27
# Cmake-dcmake_install_prefix=/usr/local/mysql
# Make && make install
# CP/USR/LOCAL/MYSQL/SUPPORT-FILES/MY-LARGE.CNF/ETC/MY.CNF

5. Initializing the database

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

6. Set Boot up

# Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld
# Chkconfig Mysqld on

7. Add Environment variables

# echo ' Export path=/usr/local/mysql/bin: $PATH ' >>/etc/profile
# Source/etc/profile
8. Start MySQL Service
#/etc/init.d/mysqld Start

9. Modify MySQL password and remote access after loading

# mysql-u Root-p
Enter Password: Default no password, direct return
Mysql>use MySQL;
mysql> Update user Set Password=password ("123456"); Modify password
mysql> Update user set ' host ' = '% ' where ' user ' = ' root ' limit 1; modifying remote access
MySQL > Exit//Exit

10. Restart MySQL Service

#/etc/init.d/mysqld Restart

Second, the source code compiled installation mysql-5.5.36


The first is to install the CMake environment. Because Bo main test machine is Ubuntu, so directly with Apt-get install CMake command to install, Yum believe should also be the same. Alternatively, you can compile the installation in the following steps.


wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz
Tarx ZVFC cmake-2.8.12.2.tar.gz
CD cmake-2.8.12.2
./configure
Make && make install

After the installation is complete, perform cmake-version and make sure that it is installed correctly.

Then download the MySQL latest source package, compile the installation.


wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.36.tar.gz
Tar xzvf mysql-5.5.36.tar.gz
CD mysql-5.5.36
Cmake-dcmake_install_prefix=/usr/local/mysql-dextra_charsets=all-ddefault_charset=utf8-ddefault_collation=utf8 _general_ci-dwith_readline=1-dwith_ssl=system-dwith_zlib=system-dwith_embedded_server=1-denabled_local_infile= 1-dmysql_datadir=/data/mysql
Make && make install

Here the blogger encounters an error about SSL, and the prompt is shown below.

Linking C shared module adt_null.so
[65%] Built Target Audit_null
Scanning dependencies of Target vio
[65%] Building C Object VIO/CMAKEFILES/VIO.DIR/VIO.C.O
[65%] Building C Object VIO/CMAKEFILES/VIO.DIR/VIOSOCKET.C.O
[65%] Building C Object VIO/CMAKEFILES/VIO.DIR/VIOSSL.C.O
/root/mysql-5.5.36/vio/viossl.c:in function ' Ssl_do ':
/root/mysql-5.5.36/vio/viossl.c:175:error: ' Ssl_op_no_compression ' undeclared (in the This function)
/root/mysql-5.5.36/vio/viossl.c:175:error: (Each undeclared identifier are reported only once
/root/mysql-5.5.36/vio/viossl.c:175:error:for each function it appears in.)
MAKE[2]: * * * [VIO/CMAKEFILES/VIO.DIR/VIOSSL.C.O] Error 1
MAKE[1]: * * * [Vio/cmakefiles/vio.dir/all] Error 2
Make: * * * [ALL] Error 2

The reason for this problem is that mysql5.5 cannot be compiled in openssl-1.0.0 and later. If you do not need SSL to remove the With_ssl configuration items, you can also upgrade the OpenSSL version, and a more convenient way to make a patch before cmake.


wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.36.tar.gz
Tar xzvf mysql-5.5.36.tar.gz
CD mysql-5.5.36
Wget-c "http://bugs.mysql.com/file.php?id=19941&bug_id=68999"-O Mysql-openssl.patch
Patch-p1 < span > Mysql-openssl.patch

Finally, copy the configuration file, modify it.


CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF
Sed '/skip-external-locking/i\datadir =/data/mysql '-i/etc/my.cnf
Sed-i ' s: #innodb: Innodb:g '/etc/my.cnf
Sed-i ' S:/usr/local/mysql/data:/data/mysql:g '/etc/my.cnf

Start MySQL, Success!

Third, the source code compiles installs the MySQL5.6.16

The installation of mysql5.6.16 is somewhat different from the previous 5.5 and 5.1, and is no longer used when compiling./configure to proceed, using the CMake command to compile the project.

Preparing the compilation environment

Because my Linux is just installed, need to install a lot of necessary procedures.


Yum-y install make gcc-c++ cmake bison-devel ncurses-devel gcc \
autoconf automake zlib* fiex* libxml* libmcrypt*
Download MySQL

Enter http://dev.mysql.com/downloads/mysql/'s Source/generic Linux (architecture independent), compressed TAR Archive, File mysql-5.6.16.tar.gz.

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.16.tar.gz
Tar xvf mysql-5.6.16.tar.gz
CD mysql-5.6.16

Compiling source code

Next organize the project


CMake \
-dcmake_install_prefix=/usr/local/mysql \
-dmysql_datadir=/data/mysql/data \
-DSYSCONFDIR=/ETC \
-dwith_myisam_storage_engine=1 \
-dwith_innobase_storage_engine=1 \
-dwith_memory_storage_engine=1 \
-dwith_readline=1 \
-dmysql_unix_addr=/tmp/mysql/mysql.sock \
-dmysql_tcp_port=3306 \
-denabled_local_infile=1 \
-dwith_partition_storage_engine=1 \
-dextra_charsets=all \
-ddefault_charset=utf8 \
-ddefault_collation=utf8_general_ci
Note that this cmake is an alternative to the previous./configure step. If you need more parameters, please refer to http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html.

There are sometimes similar problems.

Googlemock is not found. gtest-based The unit tests would be disabled. You can run CMake. -denable_downloads=1 to automatically download and builds required components from source.
-if You are inside a firewall, your may need to using an HTTP proxy:export http_proxy=http://example.com:80
parameter-D Enable_downloads=1 Automatic Download. The
has network restrictions to set up HTTP proxy export http_proxy=http://example.com:80. Environment variable http_proxy is also used by other tools such as curl. Although Yum can recognize uppercase or lowercase http_proxy, curl requires that the name of the environment variable be lowercase.
If this cmake has a problem with this step, cmake it again once it is resolved. If the output looks like this, then that's fine.


--Running CMake version 2.6.4
--MySQL 5.6.16
--Packaging as:mysql-5.6.16-linux-x86_64
--Have_visibility_hidden
--Have_visibility_hidden
--Have_visibility_hidden
--Using CMake version 2.6.4
--Not building NDB
--Library mysqlclient depends on OSLIBS-LPTHREAD;M;RT;DL
--gmock_source_dir:/root/mysql-5.6.16/source_downloads/gmock-1.6.0
--Gtest_libraries:gmock;gtest
--Library MySQLServer depends on OSLIBS-LPTHREAD;M;RT;CRYPT;DL
--Configuring done
--Generating done
--Build the files have been written to:/root/mysql-5.6.16
Then compile the source code

Make && make install

Compile time slowly, wait ...

Modify file permissions, build a database


Groupadd MySQL
Useradd-r-G MySQL MySQL
Cd/usr/local/mysql
Chown-r Mysql:mysql.
scripts/mysql_install_db--user=mysql--ldata=/data/mysql/data
Chown-r Root.
Chown-r MySQL Data
Description: Parameter--ldata describes the directory where your data files are stored, and if you use the default path, then this parameter can be removed. If you do not add this parameter, but you specify a different directory in the configuration file (see the DataDir configuration below), a similar hint will appear when you start MySQL:

Starting MySQL. error! The server quit without updating PID file (/data/mysql/data/vm_208.pid).
The workaround for this is to add the--ldata parameter, specify the same value as DataDir in the configuration file, and then perform the mysql_install_db again.

Set configuration file

MySQL 5.6.8 started, not in the distribution of my.cnf and other configuration of the demo, so want to take a casual use is more trouble.

The default read order for MY.CNF configuration files is
File Name (above precedence) purpose
/ETC/MY.CNF Global Options
/ETC/MYSQL/MY.CNF Global Options
SYSCONFDIR/MY.CNF Global Options
$MYSQL _home/my.cnf server-specific Options
Defaults-extra-file the file specified with--defaults-extra-file=path, if any
~/.MY.CNF user-specific Options
~/.MYLOGIN.CNF Login Path Options
[Client]
port=3306
Socket=/var/lib/mysql/mysql.sock
Default-character-set = UTF8

[Mysqld]
port=3306
bind-address=127.0.0.1
Basedir=/usr/local/mysql
Datadir=/data/data/mysql/data
Socket=/var/lib/mysql/mysql.sock
User=mysql
# Disabling Symbolic-links is recommended to prevent assorted security risks
Symbolic-links=0

############# Default Settings ################
# time Zone
Default-time-zone = System
Character-set-server = UTF8
Default-storage-engine = InnoDB

[Mysqld_safe]
Log-error=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid

This is a simpler configuration for me, declaring a common variable, and if you need to optimize your performance, you need to peruse the configuration file.

Start MySQL, boot automatic startup settings

Manually start MySQL.

Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysql
/etc/init.d/mysql start
# #或者
Service MySQL Start

After the steps above, the boot auto start setting


Chkconfig--add MySQL

# #有的系统需要下面的

Chkconfig--level 345 MySQL on
can refer to: http://dev.mysql.com/doc/refman/5.6/en/automatic-start.html

Modify Root Password

The default password is empty and dangerous and needs to be modified.

Before that, for the convenience of calling MySQL, we mister into a soft chain of MySQL.


Ln-s/usr/local/mysql/bin/mysql/usr/bin/
And then modify the password


Mysql-uroot-h127.0.0.1-p
mysql> SET PASSWORD = PASSWORD (' 123456 ');
If you forget the root password in the future, you can refer to resetting the MySQL password.

Through the above steps, you can use the MySQL database, in addition, you can install phpMyAdmin for MySQL as a front-end management interface.

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.