MySQL Source code compilation

Source: Internet
Author: User

Cmake-dcmake_install_prefix=/opt/mysql \

-ddefault_charset=utf8 \

-DDEFAULT_COLLATION=UTF8_GENERAL_CI \

-DWITH_EXTRA_CHARSETS:STRING=UTF8,GBK \

-dwith_myisam_storage_engine=1 \

-dwith_innobase_storage_engine=1 \

-dwith_readline=1 \

-denabled_local_infile=1 \

-dmysql_datadir=/opt/data/mysql \

-dmysql_tcp_port=3306 \



Source Installation Mysql5.6,os (Ubuntu 14.04Lts)


  1. Download the source package to MySQL website for example: mysql-5.6.16.tar.gz

  2. Decompression TAR-XVF mysql-5.6.16.tar.gz

  3. Necessary environment preparation

      1. install CMake

        1. sudo apt-get install cmake

        2. Best is up-to-date, if the software center is not up-to-date, you can go to CMake's official download source package to compile and install

      2. install g++ compiler     sudo apt-get install g++

      3. install dependent libraries Libncurses    sudo Apt-get install Libncurses5-dev

  4. Create two directories, the MySQL home directory (basedir) and MySQL Data directory (mysqldata)

    Example: sudo mkdir/opt/mysql_5.6 sudo mkdir/opt/mysqldata

  5. into the source directory of the newly unzipped MySQL, using CMake for the configuration of the compilation environment

    With the following parameters:

    sudo cmake.

    -dcmake_install_prefix=/opt/mysql_5.6 (Specifies the directory to install to)

    -dmysql_datadir=/opt/mysqldata (Specify Data directory)

    -ddefault_charset=utf8 (Specifies the DB character set)

    -ddefault_collation=utf8_general_ci (key sentence for solving Chinese garbled characters)

    -dextra_charsets=all

    -denabled_local_infile=1

    This step is only for the compilation of the configuration, not the actual installation, just in the current directory generated makefile


  6. sudo make sudo make install (these two are the actual compilation installation)


  7. The above steps are complete, MySQL is already installed, but not yet initialized

  8. To MySQL installed Basedir, execute sudo scripts/mysql_install_db--user=root

    Perform initialization of the database, generate some db (such as test,mysql, etc.), followed by the specified user

  9.   generate MySQL configuration file
    sudo cp support-files/my-default.cnf/etc/my.cnf

    After you specify the corresponding parameters in the mysqld, for example:

      DataDir =/ Opt/mysqldata

      Port = 3306

  10. Finally can start the database, because the password has not been specified, so the first time not to enter a password, a safe mode to start the database

    sudo bin/mysqld_safe--user=root

  11. Set a password for the root user to enter the database in Safe mode

    Use MySQL;

    UPDATE user SET Password=password (' 123456 ') WHERE user= ' root ';
    FLUSH privileges;

    Alternatively, enable the script directly in the bin directory: mysqladmin-u root-p password Password

  12. Register MySQL for Ubuntu system service

    sudo cp $MYSQL _home/support-files/mysql.server/etc/init.d/mysql.server

    sudo chmod +x/etc/init.d/mysql.server

  13. Let MySQL boot up

    sudo update-rc.d-f mysql.server defaults

    Cancel boot up sudo update-rc.d-f mysql.server remove

  14. Modify MY.CNF, specify MySQL's startup user to modify MY.CNF, and add "User=root" line under the [MYSQLD] block.
  15. Use of services

    Start MySQL:service mysql.server start;

    Stop MySQL:service MySQL. Server stop;

    check MySQL running status: service MySQL. SERVER   status .

  16. Add the MySQL startup script to the PATH environment variable,

    sudo gedit/etc/environment

    After the environment variable, add:/opt/mysql_5.6/bin

    That's the bin directory inside your MySQL basedir.

    Source/etc/environment (Let it take effect immediately)




From for notes (Wiz)

MySQL Source code compilation

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.