Source compiled MySQL 5.5+ installation process full record

Source: Internet
Author: User
Tags mysql download

Beginning with MySQL version 5.5, MySQL source installation began to use CMake, the compilation and installation is a bit different from the previous version.

One, installation steps:

1. Pre-Installation Preparation work

A. Download the MySQL source package and select MySQL Community Serve source code version from the MySQL download page

Note: Do not select the Linux-generic version, this version is a compiled binary version

B. Check that the native Linux is installed make,bison,cmake,gcc-c++,ncurses, if not installed, first install the above package, the installation method is as follows:

Note: make,gcc-c++ is installed by default on the general system.

1. Install the Make compiler


[plain] view plaincopy
  1. # tar ZXVF make-3.82.tar.gz
  2. # CD make-3.82
  3. #./configure
  4. # make
  5. # make Install

Also available: Yum install make.i686 installs this package

2. Installing Bison


[Plain] view plaincopy
  1. <span style= "FONT-SIZE:13PX;" ># Tar zxvf bison-2.5.tar.gz
  2. # CD bison-2.5
  3. #./configure
  4. # make
  5. # Make Install </span>

Also available: Yum install bison.i686 installs this package

3. Installing gcc-c++


[Plain] view plaincopy
  1. # tar ZXVF gcc-c++-4.4.4.tar.gz
  2. # CD gcc-c++-4.4.4
  3. #./configure
  4. # make
  5. # make Install

Also available: Yum install gcc-c++.i686 installs this package

4. Installing CMake


[Plain] view plaincopy
  1. # tar ZXVF cmake-2.8.4.tar.gz
  2. # CD cmake-2.8.4
  3. #./configure
  4. # make
  5. # make Install

Also available: Yum install cmake.i686 installs this package

5. Installing ncurses


[Plain] view plaincopy
  1. # tar ZXVF ncurses-5.8.tar.gz
  2. # CD ncurses-5.8
  3. #./configure
  4. # make
  5. # make Install

Also available: Yum install ncurses.i686 installs this package

2. Adding MySQL Users and Groups

[plain] view plaincopy
  1. #groupadd MySQL
  2. #useradd-G mysql-s/sbin/nologin-m MySQL

Source code compilation for 3.mysql

[Plain] view plaincopy
  1. #tar ZXVF mysql-5.5.13.tar.gz
  2. #cd mysql-5.5.13
  3. #rm CMakeCache.txt
  4. #cmake. -dcmake_install_prefix=/usr/local/mysql55/-dmysql_datadir=/usr/local/mysql55/data-dwith_innobase_storage_ Engine=1-dmysql_tcp_port=3306-dmysql_unix_addr=/usr/local/mysql55/data/mysql.sock-dmysql_user=mysql-dwith_ Debug=0
  5. #make
  6. #make Install

4. After the compilation is complete, install the database

[Plain] view plaincopy
  1. # Cd/usr/local/mysql
  2. # chown-r MySQL.
  3. # chgrp-r MySQL.
  4. # scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data
  5. # Chown-r Root.
  6. # chown-r MySQL./data

After the completion of a database, the database will not start, view the log display: Can ' t open the Mysql.plugin table ... 2009-06-01 00:52can ' t open the Mysql.plugin table. Please run Mysql_upgrade to create it.

WORKAROUND: Re-execute the database installation process and bring the

[HTML]View Plaincopy
    1. --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

So it's done

5. The following command is optional and copies the MySQL configuration file to/etc

CP support-files/my-medium.cnf/etc/my.cnf

If there are my.cnf files in the original/etc directory, be sure to replace the default my system with the MY.CNF of the compiled installation. CNF, otherwise the following error will be reported:

[HTML]View Plaincopy
  1. /usr/local/mysql/bin/mysqld:table ' mysql.plugin ' doesn ' t exist
  2. 120406 23:57:45 [ERROR] Can ' t open the Mysql.plugin table. Please run Mysql_upgrade to create it.
  3. 120406 23:57:45 innodb:the InnoDB memory heap is disabled
  4. 120406 23:57:45 innodb:mutexes and rw_locks use GCC atomic builtins
  5. 120406 23:57:45 innodb:compressed tables use zlib 1.2.3
  6. 120406 23:57:45 innodb:initializing buffer pool, size = 128.0M
  7. 120406 23:57:45 innodb:completed initialization of buffer pool
  8. Innodb:the first specified data file./ibdata1 did not exist:
  9. INNODB:A new database to be created!
  10. 120406 23:57:45 innodb:setting file./ibdata1 size to ten MB
  11. Innodb:database physically writes the file full:wait ...
  12. 120406 23:57:45 innodb:log file./ib_logfile0 did not exist:new to be created
  13. innodb:setting log file./ib_logfile0 size to 5 MB
  14. Innodb:database physically writes the file full:wait ...
  15. 120406 23:57:45 innodb:log file./ib_logfile1 did not exist:new to be created
  16. innodb:setting log file./ib_logfile1 size to 5 MB
  17. Innodb:database physically writes the file full:wait ...
  18. Innodb:doublewrite Buffer not found:creating new
  19. Innodb:doublewrite Buffer Created
  20. innodb:127 rollback segment (s) active.
  21. Innodb:creating FOREIGN KEY constraint system tables
  22. Innodb:foreign key constraint system tables created
  23. 120406 23:57:46 innodb:waiting for the background threads to start
  24. 120406 23:57:47 innodb:1.1.8 started; Log sequence number 0
  25. 120406 23:57:47 [ERROR]/usr/local/mysql/bin/mysqld:can ' t create/write to file '/var/run/mysqld/ ' (errcode:2 )
  26. 120406 23:57:47 [ERROR] Can ' t start server:can ' t create PID file:no such file or directory
  27. 120406 23:57:47 mysqld_safe mysqld from PID File/var/run/mysqld/ ended

6. Start MySQL:

[plain] view plaincopy
  1. # Bin/mysqld_safe--user=mysql &
  2. # #启动mysql, see if it works
  3. # Netstat-tnl|grep 3306
  4. # or
  5. # ps-aux|grep ' MySQL '

Optional step: Set Root password:

/usr/local/mysql/bin/mysqladmin-u root password ' new-password '
/usr/local/mysql/bin/mysqladmin-u root-h localhost.localdomain password ' new-password '

This step requires the database to be started before it can be executed successfully

7. Configure the self-boot

[Plain] view plaincopy
  1. # CP Support-files/mysql.server/etc/init.d/mysqld
  2. # chmod +x/etc/init.d/mysqld
  3. # Chkconfig–add Mysqld

Or start it this way:

[Plain] view plaincopy
  1. # #将mysql的启动服务添加到系统服务中
  2. # CP Support-files/mysql.server/etc/init.d/mysql.server
  3. # #现在可以使用下面的命令启动mysql
  4. # service Mysql.server Start
  5. # #停止mysql服务
  6. # Service Mysql.server Stop
  7. # #重启mysql服务
  8. # Service Mysql.server Restart


For convenience, add the MySQL bin directory to PATH export Path=/usr/local/mysql/bin: $PATH


About recompiling issues:

Dealing with problems compiling MySQL

The solution to many problems involves reconfiguring. If you don't reconfigure, take note of the following:

    • If CMake is the run after it had previously been run,it may use information this was gathered during its previousinvo cation. This information was stored in CMakeCache.txt . WhenCMakestarts up, it looks for that file and reads its contents if it exists,on the assumption, the Informa tion is still correct. Thatassumption is invalid if you reconfigure.
    • Each time you run the CMake, you must run make again to recompile. However, want to remove old object Filesfrom Previous builds first because they were compiled using DIFFERENTCONFI Guration options.

To prevent old object files or configuration information from being used, run these commands on Unix before re-running CMake:

make cleanrm CMakeCache.txt

Transferred from:

Source compiled MySQL 5.5+ installation process full record

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: 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.