MySQL-source code compilation and installation _ MySQL

Source: Internet
Author: User
Tags crc32
MySQL-source code compilation and installation
  1. Software Environment

    1. MySQL version: 5.6.19: http://dev.mysql.com/downloads/mysql/5.6.html

    2. Linux version: CentOS-5.10-x86_64: http://mirrors.163.com/centos/5.10/isos/x86_64/CentOS-5.10-x86_64-bin-DVD-1of2.iso

  2. Preparations before installation

    1. Linux uses the Server Base version for installation, and customizes the corresponding software packages such as administrator tools and system tools. The system can use yum to install the missing dependency packages.

    2. Hanging on CentOS-5.10-x86_64-bin-DVD-1of2.iso
      Create the mounted Directory: mkdir-p/media/cdrom
      Hanging in ISO: mount-o loop/dev/cdrom/media/cdrom

    3. Use the ssh connection tool to log on to the Linux Terminal and install the required tool
      Set yum source local installation, view configuration parameters/etc/yum. repos. d/CentOS-Media.repo
      Probably in line: 12 rows "yum -- disablerepo =/* -- enablerepo = c5-media [command]"
      Add the yum installation quick command vi/root/. baserc and append "alias yumq = 'yum -- disablerepo =/* -- enablerepo = c5-media '"
      Effective for/root/. baserc configuration source/etc/. baserc
      Install tools such as cmake and gcc
      Yumq install-y gcc cmake lrzsz
      Other dependency packages can be installed usingYumq

    4. Create a dedicated account:

      groupadd mysqluseradd -r -g mysql mysql

    5. Note: $ {version} is the downloaded version number.
      Upload the "mysql.20.1_version=.tar.gz" command to the/tmp directory.
      Run the following command on the ssh logon terminal: cd/tmp
      Upload the tar package: rz, and the following prompt is displayed: mysql.${version=.tar.gz.
      Decompress mysql.${version=.tar.gz and run the command tar-xzvf mysql.${version=.tar.gz.

  3. Use cmake to compile MySQL

    1. Run the following command on the ssh logon terminal: cd/tmp/mysql. $ {version}
      Create a MySQL data file storage directory: mkdir-p/data/mysqldata/3306
      Use UTF-8 encoding and run the command: cmake.-LH to view the mysql compilation options.
      Some common parameters are as follows:
      CMAKE_INSTALL_PREFIX: specifies the installation directory of the MySQL program. The default value is/usr/local/mysql.
      DEFAULT_CHARSET: specifies the default character set of the server. the default value is latin1.
      DEFAULT_COLLATION: specifies the default server verification rules. The default value is latin1_general_ci.
      ENABLED_LOCAL_INFILE: Specifies whether local load data infile execution is allowed. the default value is OFF.
      WITH_COMMENT: specifies the compilation remarks.
      WITH_xxx_STORAGE_ENGINE: it specifies the storage engine for static compilation to mysql. by default, four engines, MyISAM, MERGE, MEMBER, and CSV, are compiled to the server, and do not need to be specified.
      WITHOUT_xxx_STORAGE_ENGINE: specifies the storage engine that is not compiled.
      SYSCONFDIR: Directory of the initialization parameter file
      MYSQL_DATADIR: Data File Directory
      MYSQL_TCP_PORT: service port number. the default value is 3306.
      MYSQL_UNIX_ADDR: socket file path. default value:/tmp/mysql. sock

    2. Run the following command to compile:
      Cmake.-DCMAKE_INSTALL_PREFIX =/usr/local/mysql/
      -DDEFAULT_CHARSET = utf8/
      -DDEFAULT_COLLATION = utf8_unicode_ci/
      -DENABLED_LOCAL_INFILE = ON/
      -DWITH_INNOBASE_STORAGE_ENGINE = 1/
      -DWITH_FEDERATED_STORAGE_ENGINE = 1/
      -DWITH_BLACKHOLE_STORAGE_ENGINE = 1/
      -DWITHOUT_EXAMPLE_STORAGE_ENGINE = 1/
      -DWITH_COMMENT = "jss edition "/
      -DMYSQL_UNIX_ADDR =/data/mysqldata/3306/mysql. sock/
      -DSYSCONFDIR =/data/MySQL data/3306

      Compile: cd/tmp/mysql. $ {version} and execute: make
      Install: make install
      Configuration:

      1. Configure mysql environment variables:
        Add/usr/local/mysql/bin to the path directory. As follows:
        Export MYSQL_HOME =/usr/local/mysql
        Export PATH = $ MYSQL_HOME/bin: $ PATH :.
        And the configuration takes effect. source/etc/profile

      2. Set permissions:
        Cd/usr/local, authorization: chown-R mysql: mysql./mysql

      3. Set Database files:
        Cd/data/mysqldata/3306/, add the required folder: mkdir data binlog tmp innodb_ts innodb_log, and set all folder permissions chown-R mysql: mysql/data

      4. Run the mysql_install_db command to create a database:
        Cd/usr/local/mysql:./scripts/mysql_install_db -- user = mysql -- datadir =/data/mysqldata/3306/data. You must enter/usr/local/mysql because the program in the bin directory needs to be used to execute the database installation script.
        The execution result is as follows:

        Installing MySQL system tables...2014-06-02 22:02:39 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2014-06-02 22:02:39 28746 [Note] InnoDB: Using atomics to ref count buffer pool pages2014-06-02 22:02:39 28746 [Note] InnoDB: The InnoDB memory heap is disabled2014-06-02 22:02:39 28746 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2014-06-02 22:02:39 28746 [Note] InnoDB: Compressed tables use zlib 1.2.32014-06-02 22:02:39 28746 [Note] InnoDB: Using CPU crc32 instructions2014-06-02 22:02:39 28746 [Note] InnoDB: Initializing buffer pool, size = 128.0M2014-06-02 22:02:39 28746 [Note] InnoDB: Completed initialization of buffer pool2014-06-02 22:02:39 28746 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!2014-06-02 22:02:39 28746 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB2014-06-02 22:02:39 28746 [Note] InnoDB: Database physically writes the file full: wait...2014-06-02 22:02:39 28746 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB2014-06-02 22:02:40 28746 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB2014-06-02 22:02:40 28746 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile02014-06-02 22:02:40 28746 [Warning] InnoDB: New log files created, LSN=457812014-06-02 22:02:40 28746 [Note] InnoDB: Doublewrite buffer not found: creating new2014-06-02 22:02:40 28746 [Note] InnoDB: Doublewrite buffer created2014-06-02 22:02:40 28746 [Note] InnoDB: 128 rollback segment(s) are active.2014-06-02 22:02:40 28746 [Warning] InnoDB: Creating foreign key constraint system tables.2014-06-02 22:02:40 28746 [Note] InnoDB: Foreign key constraint system tables created2014-06-02 22:02:40 28746 [Note] InnoDB: Creating tablespace and datafile system tables.2014-06-02 22:02:40 28746 [Note] InnoDB: Tablespace and datafile system tables created.2014-06-02 22:02:40 28746 [Note] InnoDB: Waiting for purge to start2014-06-02 22:02:40 28746 [Note] InnoDB: 5.6.19 started; log sequence number 02014-06-02 22:02:40 28746 [Note] Binlog end2014-06-02 22:02:40 28746 [Note] InnoDB: FTS optimize thread exiting.2014-06-02 22:02:40 28746 [Note] InnoDB: Starting shutdown...2014-06-02 22:02:41 28746 [Note] InnoDB: Shutdown completed; log sequence number 1625977OKFilling help tables...2014-06-02 22:02:41 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2014-06-02 22:02:41 28769 [Note] InnoDB: Using atomics to ref count buffer pool pages2014-06-02 22:02:41 28769 [Note] InnoDB: The InnoDB memory heap is disabled2014-06-02 22:02:41 28769 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins2014-06-02 22:02:41 28769 [Note] InnoDB: Compressed tables use zlib 1.2.32014-06-02 22:02:41 28769 [Note] InnoDB: Using CPU crc32 instructions2014-06-02 22:02:41 28769 [Note] InnoDB: Initializing buffer pool, size = 128.0M2014-06-02 22:02:41 28769 [Note] InnoDB: Completed initialization of buffer pool2014-06-02 22:02:41 28769 [Note] InnoDB: Highest supported file format is Barracuda.2014-06-02 22:02:41 28769 [Note] InnoDB: 128 rollback segment(s) are active.2014-06-02 22:02:41 28769 [Note] InnoDB: Waiting for purge to start2014-06-02 22:02:42 28769 [Note] InnoDB: 5.6.19 started; log sequence number 16259772014-06-02 22:02:42 28769 [Note] Binlog end2014-06-02 22:02:42 28769 [Note] InnoDB: FTS optimize thread exiting.2014-06-02 22:02:42 28769 [Note] InnoDB: Starting shutdown...2014-06-02 22:02:43 28769 [Note] InnoDB: Shutdown completed; log sequence number 1625987OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:  ./bin/mysqladmin -u root password 'new-password'  ./bin/mysqladmin -u root -h mysql.master.clibing.org password 'new-password'Alternatively you can run:  ./bin/mysql_secure_installationwhich will 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 . ; ./bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.pl  cd mysql-test ; perl mysql-test-run.plPlease report any problems at http://bugs.mysql.com/The latest information about MySQL is available on the web at  http://www.mysql.comSupport MySQL by buying support/licenses at http://shop.mysql.comNew default config file was created as ./my.cnf andwill be used by default by the server when you start it.You may edit this file to change server settingsWARNING: Default config file /etc/my.cnf exists on the systemThis file will be read by default by the MySQL serverIf you do not want to use this, either remove it, or use the--defaults-file argument to mysqld_safe when starting the server

      5. Copy the initialization parameter file to the appropriate path. the default path of the initialization parameter file is/data/mysqldata/3306, therefore, copy the parameter file to this path. do not copy the file to the wrong path:
        Cp/usr/local/mysql/support-files/my-default.cnf/etc/my. cnf, modify the configuration parameters, and add the following content

        datadir=/data/mysqldata/3306/datatmpdir=/data/mysqldata/3306/tmp

      6. Run and test whether it is normal

        1. Start in safe mode:/usr/local/mysql/bin/mysqld_safe &

          [1] 29479[root@mysql mysql]# 140602 22:34:30 mysqld_safe Logging to '/data/mysqldata/3306/data/mysql.master.clibing.org.err'.140602 22:34:30 mysqld_safe Starting mysqld daemon with databases from /data/mysqldata/3306/data

          Detection: ps-aef | grep mysqld
          Set the root password:/usr/local/mysql/bin/mysqladmin-uroot password '000000'-S/data/mysqldata/123456/mysql. sock

        2. Configure the startup script and copy cp/usr/local/mysql/support-files/mysql. server/etc/init. d/mysqld
          The path for editing the script basedir and datadir is as follows:

          basedir=/usr/local/mysqldatadir=/data/mysqldata/3306/data

          Set the executable permission chmod a + x/etc/init. d/mysqld
          Disable the msyql server: service mysqld stop

          Starting MySQL.[  OK  ]

          Start the msyql server: service mysqld start

          Shutting down MySQL.[  OK  ]

        3. Log on to mysql-uroot-p and enter the user password 123456. the following message is displayed:

          Welcome to the MySQL monitor. commands end with; or/g. your MySQL connection id is 2 Server version: 5.6.19 Source distributionCopyright (c) 2000,201 4, Oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. other names may be trademarks of their respectiveowners. type 'help; 'or'/h' for help. type '/C' to clear the current input statement. /** execute the database in the current system */mysql> show databases; + -------------------- + | Database | + -------------------- + | information_schema | mysql | performance_schema | test | + ------------------ + 4 rows in set (0.00 sec)

        4. Disable mysql server: service mysqld stop.

    3. FAQs

      1. Error:

        /tmp/mysql-5.6.19/sql/handler.cc:462: undefined reference to `ha_partition::initialize_partition(st_mem_root*)'../../../sql/libsql.a(sql_partition_admin.cc.o): In function `Sql_cmd_alter_table_truncate_partition::execute(THD*)':/tmp/mysql-5.6.19/sql/sql_partition_admin.cc:822: undefined reference to `ha_partition::truncate_partition(Alter_info*, bool*)'collect2: ld returned 1 exit statusmake[2]: *** [storage/perfschema/unittest/pfs_connect_attr-t] Error 1make[1]: *** [storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/all] Error 2make: *** [all] Error 2

        Solution: remove-DWITHOUT_PARTITION_STORAGE_ENGINE = 1/

      2. Configure mysql quick logon.
        Vi ~ /. My. cnf

        [client]user=rootport=3306host=localhostpassword=123456

        Save and exit. run mysql to log on.

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.