MySQL5.5 source code installation _ MySQL

Source: Internet
Author: User
Install bitsCN.com from MySQL5.5 source code

Install MySQL 5.5 source code

First of all, we need to prepare MySQL. As for where to download it, we don't need to talk about it. it's hard to be a smart friend. The MySQL version used in this article is 5.5.29. if the reader has prepared the version or other versions of MySQL 5.5, The following describes how to install MySQL 5.5. All operations in this article are completed under the virtual machine.

Step 1: Copy the MySQL 5.5 source code package to the virtual machine

[Root @ serv01 ~] # Yum install/usr/bin/scp-y

[Root @ larrywen ule-mysql] # scpmysql-5.5.29.tar.gz 192.168.1.11:/opt

Root@192.168.1.11's password:

Mysql-5.5.29.tar.gz 100% 24 MB 23.7 MB/s

Step 2: make and other commands are required to compile the source code. Therefore, we need to install the development kit.

[Root @ serv01 ~] # Yum grouplist | grep Devel

Additional Development

Desktop Platform Development

Development tools

Server Platform Development

[Root @ serv01 ~] # Yum groupinstall "Development tools"-y

Step 3: decompress the source code package to the/usr/src Directory./usr/src is the recommended command.

[Root @ serv01 opt] # tar-xvf mysql-5.5.29.tar.gz-C/usr/src/

Step 4: Enter the MySQL decompression Directory

[Root @ serv01 opt] # cd/usr/src/mysql-5.5.29/

# Installation help documentation (refer to this file for installation)

[Root @ serv01 mysql-5.5.29] # vim INSTALL-SOURCE

Shell> tar zxvf mysql-VERSION.tar.gz

Shell> cd mysql-VERSION

Shell> cmake.

Shell> make

Shell> make install

# End of source-build specific instructions

# Postinstallation setup

Shell> cd/usr/local/mysql

Shell> chown-R mysql.

Shell> chgrp-R mysql.

Shell> scripts/mysql_install_db -- user = mysql

Shell> chown-R root.

Shell> chown-R mysql data

# Next command is optional

Shells> cp support-files/my-medium.cnf/etc/my. cnf

Shell> bin/mysqld_safe -- user = mysql &

# Next command is optional

Shell> cp support-files/mysql. server/etc/init. d/mysql. server

Step 5: because the configuration environment requires cmake and MySQL depends on the ncurses-devel package, we install cmake and ncurses-devel

[Root @ serv01 mysql-5.5.29] # yum install cmake-y

[Root @ serv01 mysql-5.5.29] # yum install ncurses-devel-y

Step 6: Key Steps. This step is also different from MySQL 5.1. use the cmake command to configure the environment, as shown below:

[Root @ serv01 mysql-5.5.29] # cmake ./

-DCMAKE_INSTALL_PREFIX =/usr/local/mysql/

-DWITH_INNOBASE_STORAGE_ENGINE = 1/

-DWITH_MYISAM_STORAGE_ENGINE = 1/

-DWITH_MEMORY_STORAGE_ENGINE = 1/

-DDEFAULT_CHARSET = utf8/

-DDEFAULT_COLLATION = utf8_general_ci/

-DWITH_EXTRA_CHARSETS = all/

-DMYSQL_TCP_PORT = 3306/

-DMYSQL_UNIX_ADDR =/tmp/mysql. sock/

-DMYSQL_DATADIR =/usr/local/mysql/data

Explanation:

-DCMAKE_INSTALL_PREFIX =/usr/local/mysql: MySQL installation directory. we recommend that you install it in this directory.

-DWITH_INNOBASE_STORAGE_ENGINE = 1: install the InnoDB storage engine.

-DWITH_MYISAM_STORAGE_ENGINE = 1: install the MyISAM storage engine.

-DWITH_MEMORY_STORAGE_ENGINE = 1: install the memory storage engine.

-DDEFAULT_CHARSET = utf8: the default encoding is utf8.

-DDEFAULT_COLLATION = utf8_general_ci: the default verification rule is utf8_general_ci.

-DWITH_EXTRA_CHARSETS = all: all other codes are supported.

-DMYSQL_TCP_PORT = 3306: MySQL port is 3306

-DMYSQL_UNIX_ADDR =/tmp/mysql. sock: specifies the SOCK file path.

-DMYSQL_DATADIR =/usr/local/mysql/data: MySQL data directory

Step 7: compile and install

[Root @ serv01 mysql-5.5.29] # make & make install

# Confirm that the installation directory exists

[Root @ serv01 mysql-5.5.29] # ls/usr/local/mysql/

Bin COPYING data docs include INSTALL-BINARY lib man mysql-test README scripts share SQL-plugin support-files

Step 8: add a mysql group and user

[Root @ serv01 opt] # groupadd-g 500 mysql

[Root @ serv01 opt] # useradd-u 500-g 500-r-M-s/sbin/nologin mysql

Step 9: Copy the configuration file and startup script, and modify the execution permission of the startup script.

[Root @ serv01 mysql-5.5.29] # cpsupport-files/my-medium.cnf/etc/my. cnf

Cp: overwrite '/etc/my. cnf '? Y

[Root @ serv01 mysql-5.5.29] # cpsupport-files/mysql. server/etc/init. d/mysqld

[Root @ serv01 mysql-5.5.29] # chmod a + x/etc/init. d/mysqld

[Root @ serv01 mysql-5.5.29] # ls/usr/local/mysql/data/

Mysql test

Step 10: change the owner and Group of the mysql Directory, modify the my. cnf file, and add the data directory.

[Root @ serv01 mysql-5.5.29] # chown mysql. mysql/usr/local/mysql/-R

[Root @ serv01 mysql-5.5.29] # vim/etc/my. cnf

[Root @ serv01 mysql-5.5.29] # cat/etc/my. cnf | grep datadir

Datadir =/usr/local/mysql/data

Step 2: modify the permissions of mysql_install_db to make it executable and perform initialization.

[Root @ serv01 mysql-5.5.29] # chmod a + xscripts/mysql_install_db

[Root @ serv01 mysql-5.5.29] #./scripts/mysql_install_db -- user = mysql -- datadir =/usr/local/mysql/data/-- basedir =/usr/local/mysql/

WARNING: The host 'serv01 .host.com 'could notbe looked up with resolveip.

This probably means that your libc librariesare not 100% compatible

With this binary MySQL version. The MySQLdaemon, mysqld, shocould work

Normally with the exception that host nameresolving will not work.

This means that you should use IP addressesinstead of hostnames

When specifying MySQL privileges!

Installing MySQL system tables...

OK

Filling help tables...

OK

To start mysqld at boot time you have to copy

Support-files/mysql. server to the right placefor your system

Please remember to set a password for THEMySQL root USER!

To do so, start the server, then issue thefollowing commands:

/Usr/local/mysql // bin/mysqladmin-u rootpassword 'new-password'

/Usr/local/mysql // bin/mysqladmin-u root -hserv01.host.com password 'new-password'

Alternatively you can run:

/Usr/local/mysql // bin/mysql_secure_installation

Which will also give you the option ofremoving the test

Databases and anonymous user created bydefault. This is

Stronugly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon:

Cd/usr/local/mysql/;/usr/local/mysql // bin/mysqld_safe &

You can test the MySQL daemon withmysql-test-run.pl

Cd/usr/local/mysql // mysql-test; perlmysql-test-run.pl

Please report any problems with the/usr/local/mysql // scripts/mysqlbug script!

Step 2: Start MySQL. if SUCCESS occurs, congratulations, MySQL is started successfully. If an error occurs, do not worry. troubleshoot the error according to the log.

[Root @ serv01 mysql-5.5.29] #/etc/init. d/mysqld start

Starting MySQL... SUCCESS!

[Root @ serv01 mysql-5.5.29] # ll/usr/local/mysql/data/-d

Drwxr-xr-x. 5 mysql 4096 Sep 4/usr/local/mysql/data/

Step 2: Add and make the environment variables take effect.

[Root @ serv01 mysql-5.5.29] # vim ~ /. Bash_profile

[Root @ serv01 mysql-5.5.29] #.! $

.~ /. Bash_profile

[Root @ serv01 mysql-5.5.29] # cat ~ /. Bash_profile | grep PATH

PATH =/usr/local/mysql/bin/: $ PATH: $ HOME/bin

Export PATH

Step 2: log on to mysql and check the version. if the version number is displayed, the installation is successful.

[Root @ serv01 mysql-5.5.29] # mysql

Welcome to the MySQL monitor. Commands end with; or/g.

Your MySQL connection id is 1

Server version: 5.5.29-log Sourcedistribution

Copyright (c) 2000,201 2, Oracle and/or itsaffiliates. All rights reserved.

Oracle is a registered trademark of OracleCorporation and/or its

Affiliates. Other names may be trademarks oftheir respective

Owners.

Type 'help; 'or'/h' for help. type'/C' toclear the current input statement.

Mysql> select version ();

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

| Version () |

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

| 5.5.29-log |

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

1 row in set (0.00 sec)

Mysql> exit

Bye

To install multiple MySQL instances, modify the port and the sock file.

[Root @ serv01 mysql-5.5.29] # cat/etc/my. cnf | grep-e sock-e port

Port = 3306

Socket =/tmp/mysql. sock

BitsCN.com

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.