centos6.5 Compiling and installing mysql5.6.20

Source: Internet
Author: User
Tags openssl

centos6.5 Compiling and installing mysql5.6.20

A. Preparatory work

1 Yum installs each dependent package

[Email protected] ~]# yum–y install gcc gcc-devel gcc-c++ gcc-c++-devel zlib* ncurses-devel ncurses OpenSSL openssl-de Vel Bison bison-devel Libaio

[Email protected] ~]# yum–y install CMake

2. new MySQL Group and user

[[email protected] ~]# Groupadd MySQL

[[email protected] ~]# useradd–g mysql–s/sbin/nologin MySQL

3. Directory Preparation

[Email protected] ~]# mkdir–p/hywl/mysql/etc

[Email protected] ~]# Mkdir–p/hywl/mysql/data

[Email protected] ~]# mkdir–p/hywl/mysql/tmp

[Email protected] ~]# chown–r mysql.mysql/hywl/mysql

4. unzip MySQL and go to the installation directory

Copy mysql-5.6.20.tar.gz to the /home/mysql directory under

[Email protected] ~]# tar zxvf mysql-5.6.20.tar.gz

[Email protected] ~]# CD mysql-5.6.20

two. Compiling and installing

1  . Download Gmock-1.6.0.zip to the /home/mysql/mysql-5.6.20/source_downloads directory and compile the installation:

[Email protected] mysql-5.6.20]# CD source_downloads/

[Email protected] source_downloads]# Unzip Gmock-1.6.0.zip

[Email protected] source_downloads]# CD gmock-1.6.0

[Email protected] gmock-1.6.0]#./configure

[[email protected] gmock-1.6.0]# make

[Email protected] gmock-1.6.0]# CD.

2. compiling MySQL

[Email protected] mysql-5.6.20]# cmake–dcmake_install_prefix=/hywl/mysql \

-DSYSCONFDIR=/HYWL/MYSQL/ETC \

-dmysql_datadir=/hywl/mysql/data \

-dmysql_tcp_port=3306 \

-dmysql_unix_addr=/hywl/mysql/tmp/mysqld.sock \

-dmysql_user=mysql \

-dextra_charsets=all \

-dwith_readline=1 \

-dwith_ssl=system \

-dwith_embedded_server=1 \

-denabled_local_infile=1 \

-dwith_innobase_storage_engine=1 \

-denable_downloads=1

* If an error occurs, delete mysql-5.6.20 under the directory CmakeCache.txt re-use CMake to compile and install

3. Installation

[[email protected] mysql-5.6.20]# make && make install time is a bit long.

three . MySQL Configuration

1. link to client library files ( If this step is not performed, the MySQL file will not be found at PHP compile time .) )

[Email protected] mysql-5.6.20]# ln–s/hywl/mysql/lib/libmysqlclient.so.18/usr/lib64/libmysqlclient.so.18

PS : I'm using a - bit CentOS, If you are using the + bit please use ln–s/hywl/mysql/lib/libmysqlclient.so.18/usr/lib/libmysqlclient.so.18

2.MySQL configuration of the startup file

[email protected] mysql-5.6.20]# CP support-files/mysql.server/etc/init.d/mysqld

[Email protected] mysql-5.6.20]# chmod +x/etc/init.d/mysqld

[Email protected] mysql-5.6.20]# Vim/etc/init.d/mysqld

Basedir=/hywl/mysql

Datadir=/hywl/mysql/data

// Modify the above 2 the path of the line can be

3. Setting up a MySQL configuration file

[email protected] mysql-5.6.20]# CP support-files/my-default.cnf/hywl/mysql/etc/my.cnf

[Email protected] mysql-5.6.20]# RM–RF/ETC/MY.CNF

[Email protected] mysql-5.6.20]# LN–S/HYWL/MYSQL/ETC/MY.CNF/ETC/MY.CNF

4. Initializing the database

[Email protected] mysql-5.6.20]# Cd/hywl/mysql

[Email protected] mysql]#/scripts/mysql_install_db–user=mysql–basedir=/hywl/mysql–datadir=/hywl/mysql/data

5. link MySQL command (This step can make us much more convenient, can not write the path of the command, can also write /etc/profile PATH Medium)

You can modify environment variables: Vi/etc/profile

Add a line: export Path=/hywl/mysql/bin: $PATH

650) this.width=650, "style=" Border-bottom: #ddd 1px solid;border-left: #ddd 1px solid;background:url ("/e/u261/lang/ Zh-cn/images/localimage.png ") no-repeat center;border-top: #ddd 1px solid;border-right: #ddd 1px solid;" Src= "/e/u261/ Themes/default/images/spacer.gif "width=" 609 "height=", alt= "Spacer.gif"/>

[[email protected] MySQL] #source/etc/profile

When you look at the system environment variables, you can see that the added stuff is already in effect.

[email protected] mysql]# Echo $PATH

You can also:

[[email protected] MySQL] #cd/usr/sbin

[Email protected] sbin]# ln–s/hywl/mysql/bin/*

6. start MySQL and set it to boot

[[Email protected] sbin]# service mysqld start; Chkconfig mysqld on

Starting MySQL. success!

7. Set the MySQL root user's password

[[email protected] ~]# mysqladmin–u root password mysql

It is strongly not recommended to set the password of the database simple

8. Delete the user with a blank user password

[Email protected] ~]# Mysql–u root–p

Enter Password:

mysql> use MySQL;

Mysql> select Host,user,password from User;

+-----------+------+-------------------------------------------+

| Host | User | Password |

+-----------+------+-------------------------------------------+

| localhost | Root | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 |

| webserver |                                          Root | |

| 127.0.0.1 |                                          Root | |

| :: 1 |                                          Root | |

|      localhost |                                          | |

|      webserver |                                          | |

+-----------+------+-------------------------------------------+

6 rows in Set (0.00 sec)

mysql> Delete from user where password= "";

Query OK, 5 rows Affected (0.00 sec)

mysql> flush Privileges;

Query OK, 0 rows Affected (0.00 sec)

Mysql> select Host,user,password from User;

+-----------+------+-------------------------------------------+

| Host | User | Password |

+-----------+------+-------------------------------------------+

| localhost | Root | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 |

+-----------+------+-------------------------------------------+

1 row in Set (0.00 sec)

Mysql> exit;

9 How to know where your data directory is. If you run multiple servers, you should know where all the data directories are, but if you don't know the exact location, find it by multiple methods:

9.1 Use mysqladmin variables to get the data directory path name directly from your server. Find the value of the DataDir variable, on Unix, whose output resembles the following:
%mysqladmin-u username-p variables

+----------------------+----------------------+
| variable_name | Value |
+----------------------+----------------------+
| Back_log | 5 |
| Connect_timeout | 5 |
| Basedir | /var/local/|
| DataDir | /usr/local/var/|
....
9.2 Finding the path to MySQL run
%ps-ef | grep mysqld

This article is from the "Jack" blog, please be sure to keep this source http://396386.blog.51cto.com/386386/1543301

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.