Install MySQL compilation installation on Ubuntu

Source: Internet
Author: User

Why do you want to toss?
First of all, it is very easy to install software such as MySQL on Ubuntu, which is simple enough to cover the installation on Windows, a sudo apt-get install can be done. If you want to install MySQL in the easiest way, then this article is not for you; if you like "toss", you are interested to know what the sudo apt-get install has done for you, are interested in understanding the details of internal Linux and want to try to compile your own software, So you are the target reader of this article, and I hope you get the benefit from this article.

Several major steps to compile and install:

    1. Pre-compilation preparation work
    2. Initial knowledge cmake--configuring MySQL compilation options
    3. Compiling the installation
    4. Post-installation MySQL configuration
    5. Set the boot automatically start MySQL service



First, pre-compilation preparation work

    • Official website Download source Code (click here to go to download page) Select source Code–>generic Linux (mysql-version.tar.gz) (Ps:chrome Access this page, you may encounter an abnormal display, Recommended for FF access)
    • It is suggested that interested children's shoes read the extracted MySQL directory under the relevant documentation, there are many important information. For example, this article and most of the similar articles are referenced from the Install-source documentation.
    • Create MySQL users and user groups for easy management
      code:sudo groupadd mysql code:sudo useradd-r-g MySQL MySQL


Ii. initial knowledge cmake--configuring MySQL compilation options
MySQL 5.5 compiler tool changed from Autotool to CMake (for more information about CMake, please google for yourself). The MySQL team also wrote a autotools to CMake Transition Guide, which describes the various compilation options and additional compilation options that will be listed in this document. This document has to be looked at when troubleshooting. At compile time I am used to some options (such as installation location) do not follow the default, because if the default options out of the problem, more difficult to solve (because you need not only to know what is the meaning of the option to know what the default is, but more troublesome). Enter the extracted source code directory Mysql-version

Code:CMake. \
-dcmake_install_prefix=/usr/mysql \
-dmysql_datadir=/usr/mysql/data
-ddefault_charset=utf8 \
-DDEFAULT_COLLATION=UTF8_GENERAL_CI \
-dmysql_unix_addr=/tmp/mysqld.sock \
-dwith_debug=0 \
-dwith_innobase_storage_engine=1


Some of the main parameter descriptions:

References:Option name option meaning
Dcmake_install_prefix Installation Path
Dmysql_datadir database path
Ddefault_charset default Characters
Ddefault_collation Default Character Set
DMYSQL_UNIX_ADDR Connection Database Socket path
A Dwith_debugbool value that indicates whether debug mode is turned on


Here I started with an oversight: only setting Ddefault_charset and not setting ddefault_collation, so it always appears

References:COLLATION ' latin1_swedish_ci ' isn't valid for CHARACTER SET ' UTF8 '



Third, compile and install

Code:sudo make
sudo make install


The problem at this stage is less likely. But remember to do it with root, make and make install, because the installation path is not the home, but/usr, must have root permission to write operations

Iv. post-installation MySQL configuration
The main problem is here. The root cause of the problem is the configuration file and the default configuration. Because the source code is installed and the installation location is not the default location, there are some options that must be made to make MySQL work correctly

  1. Go to the post-installation directory execution code:sudo chown-r mysql. code:chgrp-r MySQL. code:sudo bin/scripts/mysql_install_db \
    --user=mysql \
    --basedir=/usr/mysql \
    --datadir=/usr/mysql/data \
    --no-defaults
  2. Remember that there is a –no-defaults option in the back, and if this option is not available, the program will automatically load the default profile, and you have not yet finished writing the configuration file, so it is likely that you are loading the wrong information. If the command is successful, congratulations, your mysqly can start successfully. If there is an error in this step, do not worry, the relevant log and mysqld boot messages provide enough information to help you trouble shooting (that's how I came along ...) After completion, execute the code:chown-r root.
    Chown-r MySQL Data These two instructions should be security considerations.
  3. Configuring the My.cnf--mysql configuration file is an important step that will not require you to write a large segment of the parameters at startup when you are properly configured.
    The first thing you should know: MySQL looks for the path and order of the configuration files. The location at the beginning of the search is/etc/my.cnf after/etc/mysql/my.cnf so what we're going to do is build the configuration file my.cnf in one of these two places. MySQL has prepared the default configuration files for several different scenarios (in/usr/mysql/support-files/) so we can copy a location code to the above :sudo cp/usr/mysql/ Support-files/my-medium.cnf/etc/mysql/my.cnf
    Usually we start mysqld by passing in the appropriate parameters to the script. So add the following in the/ETC/MYSQL/MY.CNF: reference:[mysqld]
    Basedir=/usr/mysql
    Datadir=/usr/mysql/data
    User=mysql more about the MY.CNF configuration is no longer speaking, but for the daily development needs should continue to configure, this part of the content is referred to Google search and MySQL manual bar


Five, set the boot automatically start the MySQL service
This section explains how to add MySQL to start automatically at boot time. MySQL Manual The content of this section is inaccurate and does not cover Debian Linux distributions.
MySQL has provided the default script Mysql.server (in the [MySQL installation directory]/support-files/), first enter the directory, try to run the script

Code:sudo./mysql.server start

If it works, it executes

Code:sudo cp mysql.server/etc/init.d/mysql


Debian/ubuntu on boot service management is not using Chkconfig, but using sysv-rc-conf, try to execute

Code:sudo sysv-rc-conf

If the prompt is not installed,

Code:sudo apt-get install sysv-rc-conf

Then run, the tool is a graphical interface, very intuitive here does not describe how to use, we need to do is to find the "MySQL" column, selected "3" "4" "5" the three columns, so that completed the boot automatically start MySQL daemon.

MySQL installation is basically completed, I hope you can and I like in the "toss" in the process of some gains, "pain and happiness"!

Original link: Http://liuyix.com/install-mysql-on-ubuntu-10-04-from-source

Install MySQL compilation installation on Ubuntu

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.