Share the compilation and installation records of MySQL 5.5.8 source code in Linux

Source: Internet
Author: User

System: Ubuntu 10.10
Mysql source file: mysql-5.5.8.tar.gz
Install required tools: cmake, GNU make, gcc, Perl, libncurses5-dev, bison (optional), chkconfig
Note:
1. There are several bugs in the official source code from, which were manually modified by referring to the official instructions before compilation.

Official links: http://lists.mysql.com/commits/126782
2. Official version 5.5 Reference Manual: http://dev.mysql.com/doc/
Sweated a bit, 3392 page reference manual!
=> Tool installation:
1. cmake
---- You have not compiled and installed cmake yourself.
---- Shell :~ $ Sudo apt-get install cmake
---- Version: 2.8.2
2. GNU make
---- Ubuntu built-in
---- Version 3.81
3. GCC
---- Ubuntu built-in
---- Version: 4.4.5 (Official Document: Must be later than 3.2)
4. Perl
---- Ubuntu built-in
---- Version: 5.10.1
5. libncurses5-dev (ncurses-devel)
---- If this package is missing, an error will be reported during cmake.
---- The package name On Debian/Ubuntu is libncurses5-dev, and RedHat corresponds to ncurses-devel in other versions
---- Shell :~ $ Sudo apt-get install libncurses5-dev
---- Error message
------------------Www.linuxidc.com ---------------
-- MySQL 5.5.8
-- Cocould NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline. cmake: 82 (MESSAGE ):
Curses library not found. Please install appropriate package,

Remove CMakeCache.txt and rerun cmake. On Debian/Ubuntu, package name is libncurses5-dev,
On RedHat and derivates it is ncurses-devel.
Call Stack (most recent call first ):
Cmake/readline. cmake: 126 (FIND_CURSES)
Cmake/readline. cmake: 216 (MYSQL_USE_BUNDLED_LIBEDIT)
CMakeLists.txt: 256 (MYSQL_CHECK_READLINE)

-- Refreshing incomplete, errors occurred!
---------------------------------
6. bison
---- Shell :~ $ Sudo apt-get install bison
---- Optional. Without this tool, a warning is reported during make.
---- Warning record:
---------------------------------

Warning: Bison executables not found in PATH
---------------------------------
7. chkconfig
---- This is required when configuring mysql Service self-start.
---- Shell :~ $ Sudo apt-get install chkconfig
=> Install mysql:
1. decompress the source code file
---- Shell locates the directory where the source code file is located
---- Extract
Shell :~ $ Tar zxvf mysql-5.5.8.tar.gz
2. cmake operation
---- Shell located to the decompressed source code folder directory (Folder: mysql-5.5.8)
---- Cmake:
---------------------------------
Shell :~ $ Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql
-DMYSQL_DATADIR =/home/system_username/Programming/mysql/mysqldata
-DSYSCONFDIR =/etc
-DWITH_INNOBASE_STORAGE_ENGINE = 1
-DWITH_ARCHIVE_STORAGE_ENGINE = 1
-DWITH_BLACKHOLE_STORAGE_ENGINE = 1
-DWITH_FEDERATED_STORAGE_ENGINE = 1
-DWITH_PARTITION_STORAGE_ENGINE = 1
-DMYSQL_UNIX_ADDR =/tmp/mysqld. sock
-DMYSQL_TCP_PORT = 3306
-DENABLED_LOCAL_INFILE = 1
-DEXTRA_CHARSETS = all
-DDEFAULT_CHARSET = utf8
-DDEFAULT_COLLATION = utf8-general_ci
-DMYSQL_USER = mysql
Note: There is no line feed. In the official documentation, the cmake command is followed by a point that doesn't understand what it means. The command cannot be executed.
---------------------------------
Source code configuration options:
// The main directory installed by mysql. The default version 5.5.8 is/usr/local/mysql.
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql

// Custom path for saving mysql Data
-DMYSQL_DATADIR =/home/system_username/mysql/mysqldata

// Mysql configuration file address ------ The default my. cnf option file directory
-DSYSCONFDIR =/etc

// Compile storage engine xxx statically into server
/* Storage engines are built as plugins. You can build a plugin as a static module (compiled into the server)
* Or a dynamic module (built as a dynamic library that must be installed into the server using the INSTALL
* PLUGIN statement or the -- plugin-load option before it can be used). Some plugins might not support static
* Or dynamic building.
*/
-DWITH_INNOBASE_STORAGE_ENGINE = 1
-DWITH_ARCHIVE_STORAGE_ENGINE = 1
-DWITH_BLACKHOLE_STORAGE_ENGINE = 1
-DWITH_FEDERATED_STORAGE_ENGINE = 1
-DWITH_PARTITION_STORAGE_ENGINE = 1

// Unix socket file
/*
* The Unix socket file path on which the server listens for socket connections. This must be an absolute path
* Name. The default is/tmp/mysql. sock
*/
-DMYSQL_UNIX_ADDR =/tmp/mysqld. sock

// The listening port of the database server's TCP/IP connection. The default value is 3306.
-DMYSQL_TCP_PORT = 3306

// Whether to enable LOCAL capability in the client library for LOAD DATA INFILE
// Disabled by default. enabled here
-DENABLED_LOCAL_INFILE = 1

// Database encoding settings
-DEXTRA_CHARSETS = all
-DDEFAULT_CHARSET = utf8
-DDEFAULT_COLLATION = utf8-general_ci
3. Compile and install
---- Shell locate the source code folder directory
---- Execution: (it took about 20 minutes to compile)
Shell :~ $ Make
Shell :~ $ Make install

4. Subsequent Configuration
---- Enter the script directory under the mysql installation directory
Shell :~ $ Cd/usr/local/mysql/scripts
---- Use the mysql_install_db script to generate a new MySQL authorization table
./Mysql_install_db -- basedir =/usr/local/mysql -- datadir =/home/system_username/Programming/mysql/mysqldata
-- User = mysql
---- Enter the support file directory under the mysql installation directory
Shell :~ $ Cd/usr/local/mysql/support-files
---- Copy the mysql configuration file
Shell :~ $ Sudo cp my-medium.cnf/etc/my. cnf

---- Copy and modify the service file
Shell :~ $ Sudo cp mysql. server mysqld
---- Modify mysqld
Basedir =/usr/local/mysql
Datadir =/home/mysql
Mv mysqld/etc/init. d/mysqld
---- Start the service
Shell :~ $ Service mysqld start
---- Close the service
Shell :~ $ Service mysqld stop
---------------------------------
Service command:
1. commands used to manage services in Linux
2. Go to the/etc/init. d directory to find the corresponding services and perform operations such as enabling and disabling them.
3. After the preceding operations, the mysqld service file corresponds to the mysql. server File.
---------------------------------
---- Add a service to a self-starting item
Shell :~ $ Sudo chkconfig -- level 3 mysqld on

---- Set the soft connection so that mysql, mysqldump, and mysqladmin commands can be directly run in shell
Shell :~ $ Sudo ln-s/usr/local/mysql/bin/mysql/usr/bin
Shell :~ $ Sudo ln-s/usr/local/mysql/bin/mysqldump/usr/bin
Shell :~ $ Sudo ln-s/usr/local/mysql/bin/mysqladmin/usr/bin
---------------------------------
=> Mysql database Chinese garbled solution:
1. garbled Analysis
---- Access mysql from the terminal shell
Shell :~ $ Mysql
............
............
Mysql> show variables like '% character %'
---- Obtain the following database encoding information table:
+ ----------------------------------- + ------------------------------------------- +
| Variable_name | Value |
+ ------------------------------------ + ------------------------------------------- +
| Character_set_client | utf8 |
| Character_set_connection | utf8 |
| Character_set_database | latin1 |
| Character_set_filesystem | binary |
| Character_set_results | utf8 |
| Character_set_server | latin1 |
| Character_set_system | utf8 |
| Character_sets_dir |/usr/local/mysql/share/charsets/|
+ ------------------------------------ + ------------------------------------------- +
It can be seen that character_set_database and character_set_server are still the default latin1 encoding.
I don't know why, it seems that DEFAULT_CHARSET was set to utf8. View official documents
It is found that character_set_database does not support the configuration file (/etc/my. cnf) variable settings,
However, character_set_server supports setting configuration file variables.

2. Solution
---- Open the configuration file
Shell :~ $ Sudo gedit/etc/my. cnf
Then add
Character-set-server = utf8
---- Then enter mysql
Run:
Mysql> show variables like '% character %'
Result: Both character_set_database and character_set_server are changed to utf8.
---- Test:
Insert a Chinese field to the database table, and the Chinese field is displayed normally.

Note: 1. the following method can solve the problem of Chinese encoding when using version 5.1:
---- Add default-character-set = utf8 in the [mysqld] and [client] sections of the configuration file.
2. I do not know if it is the reason for manual compilation. Using the above method in the configuration file in 5.5.8 will cause the database service to fail to start.
---- The error log is as follows: (datadir/username. err is the error log file)
----------------------------------------------------
Mysqld_safe mysqld from pid file/home/cyberwym/Programming/mysql/mysqldata/cyberwym. pid ended
...........
...........
[ERROR]/usr/local/mysql/bin/mysqld: unknown variable 'default-character-set = utf8'
[ERROR] Aborting
----------------------------------------------------
---- This will cause the pid file (datadir/username. pid) to fail to be updated.
---- Remove default-character-set = utf8 in the [mysqld] and [client] sections of the configuration file, and then the database service starts normally.

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