Mysql5.5 Source Installation

Source: Internet
Author: User
Tags check character reserved

First, the article explains

Recently contacted the MySQL database, so idle to study, today demo to install MySQL with the source code, if the use of RPM package installation, personal feeling is very simple.

Environment Description:

Operating system: Rhel 5.4 x86

MySQL version: mysql-5.5.22

Second, the installation of CMake (mysql5.5 after the cmake to compile)

Before mysql5.5, direct editing can, and after 5.5 need to be compiled by CMake, in the appendix to introduce the direct compilation.

Download cmake-2.8.4.tar.gz, I was in the degree of Niang search.

[Email protected] ~]# TAR-ZXVF cmake-2.8.4.tar.gz[[email protected] ~]# CD Cmake-2.8.4[[email protected] cmake-2.8.4]#. /configure--prefix=/usr/local/cmake----Here you can use # Gmake && make install
[[email protected] cmake-2.8.4]# Make[[email protected] cmake-2.8.4]# make install

Note: Configure needs to be compiled into the directory.
Third, the installation directory to create MySQL and database storage directory

Iv. creating MySQL users and user groups

[[email protected] ~]# groupadd mysql[[email protected] ~]# useradd-r-g MySQL MySQL

V. Installation of MySQL

[[email protected] ~]# TAR-ZXVF mysql-5.5.22.tar.gz[[email protected] ~]# CD mysql-5.5.22----Compile the following error, need ncurses-devel[ [Email protected] mysql-5.5.22]#/usr/local/cmake/bin/cmake-dcmake_install_prefix=/opt/mysql5.5-dmysql_datadir=/ Opt/mysql5.5/data-ddefault_charset=utf8-ddefault_collation=utf8_general_ci-dextra_charsets=all-denabled_local_ infile=1--MySQL 5.5.22--Could not find Curses (missing:curses_library curses_include_path) CMake Error at Cmake/readli  Ne.cmake:83 (MESSAGE): Curses library not found. Please install the appropriate package, remove CMakeCache.txt and rerun CMake. On Debian/ubuntu, package name was Libncurses5-dev, on Redhat and derivates it was ncurses-devel. Call Stack (most recent call first): cmake/readline.cmake:127 (find_curses) cmake/readline.cmake:217 (mysql_use_bundled _libedit) cmakelists.txt:268 (mysql_check_readline)
--Configuring incomplete, errors occurred!----see if ncurses is installed: [[email protected] mysql-5.5.22]# Rpm-qa|grep necursesncurses-5.5-24.20060715----Installation ncurses-devel[[email protected]]# RPM-IVH ncurses-devel-5.5-24.20060715.i386.rpm warning:ncurses-devel-5.5-24.20060715.i386.rpm:header V3 DSA Signature: Nokey, key ID 37017186Preparing ... ########################################### [100%] 1:ncurses-devel ########################################### [100%]----Delete cmakecache.txt[[email protected] mysql-5.5.22]# find /-name cmakecache.txt/root/mysql-5.5.22/cmakecache.txt/root/cmake-2.8.4/cmakecache.txt/root/cmake-2.8.4/tests/ complexoneconfig/cache/cmakecache.txt/root/cmake-2.8.4/tests/complex/cache/cmakecache.txt/root/cmake-2.8.4/ tests/cmakefiles/checkfortran/cmakecache.txt/root/cmake-2.8.4/tests/complexrelativepaths/cache/cmakecache.txt[ [email protected] mysql-5.5.22]# rm/root/mysql-5.5.22/cmakecache.txtrm:remove regular file '/root/mysql-5.5.22 /CMakeCache.txt '? Yes[[email protected] mysql-5.5.22]# rm/root/cmake-2.8.4/cmakecache.txtrm:remove regular file '/root/ Cmake-2.8.4/cmakecache.txt '? Yes[[email protected] mysql-5.5.22]# RM/ROOT/CMAKE-2.8.4/TESTS/COMPLEXONECONFIG/CACHE/CMAKECACHE.TXTRM: Remove regular file '/root/cmake-2.8.4/tests/complexoneconfig/cache/cmakecache.txt '? Yes[[email protected] mysql-5.5.22]# rm/root/cmake-2.8.4/tests/complex/cache/cmakecache.txtrm:remove Regular File '/root/cmake-2.8.4/tests/complex/cache/cmakecache.txt '? Yes[[email protected] mysql-5.5.22]# RM/ROOT/CMAKE-2.8.4/TESTS/CMAKEFILES/CHECKFORTRAN/CMAKECACHE.TXTRM: Remove regular file '/root/cmake-2.8.4/tests/cmakefiles/checkfortran/cmakecache.txt '? Yes[[email protected] mysql-5.5.22]# RM/ROOT/CMAKE-2.8.4/TESTS/COMPLEXRELATIVEPATHS/CACHE/CMAKECACHE.TXTRM: Remove regular file '/root/cmake-2.8.4/tests/complexrelativepaths/cache/cmakecache.txt '? Yes----compile again: [[email protected] mysql-5.5.22]#/usr/local/cmake/bin/cmAke-dcmake_install_prefix=/opt/mysql5.5-dmysql_datadir=/opt/mysql5.5/data-ddefault_charset=utf8-ddefault_ Collation=utf8_general_ci-dextra_charsets=all-denabled_local_infile=1
[[email protected] mysql-5.5.22] #make && make install

Note:

-dcmake_install_prefix=/usr/local/mysql//installation directory

-dinstall_datadir=/usr/local/mysql/data//Database storage directory

-ddefault_charset=utf8//using UTF8 characters

-DDEFAULT_COLLATION=UTF8_GENERAL_CI//Check character

-dextra_charsets=all//Install all extended character sets

-denabled_local_infile=1//Allow import of data from local

Precautions:

When you recompile, you need to clear the old object file and cache information.

#make Clean

#rm-F CMakeCache.txt

#rm-rf/etc/my.cnf

Vi. Setting Directory Permissions

[Email protected] ~]# cd/opt/mysql5.5/[[email protected] mysql5.5]# chown-r root:mysql.     Set the owner of all files in the current directory to root, and the group is MySQL                            [[email protected] mysql5.5]# chown-r mysql:mysql data/

Vii. setting up a MySQL configuration file

[[email protected] mysql5.5]# CP support-files/my-medium.cnf/etc/my.cnf    //Add MySQL boot service to system service [email protected] mysql5.5]# CP support-files/my-medium.cnf My.cnf[[email protected] mysql5.5]# more my.cnf----add mysqld below Basedir =/opt/ mysql5.5 datadir =/opt/mysql5.5/data    [mysqld]port        = 3306socket        =/tmp/ Mysql.sockskip-external-lockingkey_buffer_size = 16mmax_allowed_packet = 1mtable_open_cache = 64sort_buffer_size = 512knet_buffer_length = 8kread_buffer_size = 256kread_rnd_buffer_size = 512kmyisam_sort_buffer_size = 8Mbasedir =/opt/ Mysql5.5datadir =/opt/mysql5.5/data

Viii. Creating a System database table

----Specify the configuration file and user here [[email protected] mysql5.5]# scripts/mysql_install_db--defaults-file=./my.cnf--user=mysql Installing MySQL system tables ... Okfilling Help Tables ... OKto start mysqld at boot time has to copysupport-files/mysql.server to the right place for your systemplease Remembe R to SET A PASSWORD for the MySQL root USER! To does, start the server, then issue the following commands:/opt/mysql5.5/bin/mysqladmin-u root password ' new-password ' /opt/mysql5.5/bin/mysqladmin-u root-h node4 password ' new-password ' Alternatively you can Run:/opt/mysql5.5/bin/mysql_ Secure_installationwhich would also give you the option of removing the testdatabases and anonymous user created by default  . This isstrongly recommended for production servers. See the Manual for more instructions. You can start the MySQL daemon with:cd/opt/mysql5.5; /opt/mysql5.5/bin/mysqld_safe &you can test the MySQL daemon with mysql-test-run.plcd/opt/mysql5.5/mysql-test; Perl MYSQL-TEST-RUN.PLPLEase report no problems with The/opt/mysql5.5/scripts/mysqlbug script! 

IX. Setting Environment variables

X. Manual start of MySQL

[[email protected] mysql5.5]#./bin/mysqld_safe--user=mysql &   //start MySQL but not stop [1] 27412[[email protected] mysql5.5]# 130728 08:34:38 mysqld_safe Logging to '/opt/mysql5.5/data/node4.err '. 130728 08:34:38 mysqld_safe Starting Mysqld Daemon with Databases From/opt/mysql5.5/data
----Here MySQL root user has not configured password, so null value. If you need to enter a password, just click Enter. [email protected] mysql5.5]#/bin/mysqladmin-u root-p shutdownenter password:130728 08:34:46 mysqld_safe mysqld From PID file/opt/mysql5.5/data/node4.pid ended[1]+ done ./bin/mysqld_safe--user=mysql

Xi. another simple way to start MySQL (MySQL has been added to the system service)

[[Email protected] mysql5.5]# service MySQL start[[email protected] mysql5.5]# service MySQL stop[[email protected] MySQL5 .5]# Service MySQL Restart

If the above command appears: MySQL unrecognized service

[Root[email protected] mysql5.5]# service MySQL startmysql.server:unrecognized service

It is possible that MySQL has not been added to the system service, which is added in another way:

[[email protected] mysql5.5]# CP support-files/mysql.server  /etc/init.d/mysql[[email protected] mysql5.5]# Service MySQL startstarting mysql                                          ... [  OK  ][[email protected] mysql5.5]# service MySQL stopshutting down MySQL.                                       [  OK  ]

Note: The main is to copy Mysql.server to/etc/init.d, named MySQL. Then use #service MySQL start to start MySQL.

12. Modify the root user password of MySQL and open remote connection

[Email protected] ~]#/opt/mysql5.5/bin/mysql-u root mysqlwelcome to the MySQL monitor. Commands End With; or \g.your MySQL connection ID is 1Server version:5.5.22-log Source distributioncopyright (c) (+), Oracle and/or I TS affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.mysql> use mysql;database changedmysql> desc user;----The ability to add remote connections to root.
Mysql> Grant all privileges on * * to [email protected] "%" identified by "root"; Query OK, 0 rows affected (0.03 sec) mysql> Update user Set Password = Password (' 123456 ') where user= ' root '; Query OK, 5 rows Affected (0.02 sec) rows matched:5 changed:5 warnings:0mysql> select Host,user,password from User where user= ' root '; +-----------+------+-------------------------------------------+| Host | User | Password |+-----------+------+-------------------------------------------+| localhost | Root | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 | | Node4 | Root | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 | | 127.0.0.1 | Root | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 | | :: 1 | Root | *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 | | % | Root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |+-----------+------+-------------------------------------------+5 Rows in Set (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.01 sec) mysql> exit; Bye[[email protected] ~]#/opt/mysql5.5/bin/mysql-u root-penter password:welcome to the MySQL monitor. Commands End With; or \g.your MySQL connection ID is 3Server version:5.5.22-log Source distributioncopyright (c) (+), Oracle and/or I TS affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.mysql> show databases;+--------------------+| Database |+--------------------+| Information_schema | | MySQL | | Performance_schema | | Test |+--------------------+4 rows in Set (0.10 sec) mysql> Select version (); +------------+| Version () |+------------+| 5.5.22-log |+------------+1 row in Set (0.02 sec)

Appendix:
1. Groupadd MySQL
2. useradd-g MySQL MySQL
3. Tar zxvf mysql-version.tar.gz
4. CD Mysql-version
5../configure--prefix=/usr/local/mysql
--without-debug
--enable-thread-safe-client
--enable-assembler
--enable-profiling
--with-mysqld-ldflags=-all-static
--with-client-ldflags=-all-static
--with-charset=latin1
--with-extra-charsets=utf8,gbk
--with-mysqld-user=mysql
--without-embedded-server
--with-server-suffix=bbk
--with-plugins=innobase,partition
6. Make
7. Make Install
8.mkdir data
9.chown mysql:mysql./data/-R
CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF
11. Under the MY.CNF mysqld tab, add:
Basedir=/opt/mysql5
Datadir=/opt/mysql5/data
/bin/mysql_install_db--default-file=./my.cnf--user=mysql
Select version ();

Original: http://www.cnblogs.com/Richardzhu/p/3220883.html

Mysql5.5 Source Installation

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.