Linux under MySQL 5.5.8 source compilation installation record sharing

  • 2020-05-12 06:19:10
  • OfStack

System: Ubuntu 10.10
mysql source file: mysql-5.5.8. tar. gz
Install the required tools: cmake, GNU make, gcc, Perl, libncurses5-dev, bison(optional), chkconfig
1. There are several parts of bug in the official source code of 2010-11-18, which were manually modified according to the official instructions before compiling.

Shows the official link: http: / / lists mysql. com/commits / 126782
2. The official version 5.5 reference manual: http: / / dev mysql. com/doc /
Sweat 1, 3392 page reference manual!
= > Tool installation:
1. cmake
-- did not compile and install cmake yourself
----shell:~$ sudo apt-get install cmake
-- version 2.8.2
2. GNU make
- Ubuntu bring
-- version 3.81
- Ubuntu bring
-- version 4.4.5(official document: must be at least 3.2)
- Ubuntu bring
-- version 5.10.1
5.libncurses5-dev (ncurses-devel)
-- if this package is missing, an error will be reported at cmake.
-- the package name on Debian/Ubuntu is libncurses5-dev, and RedHat and other versions correspond to ncurses-devel
----shell:~$ sudo apt-get install libncurses5-dev
-- report an error
-- MySQL 5.5.8
-- Could 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)

-- Configuring incomplete, errors occurred!
6. bison
----shell:~$ sudo apt-get install bison
- optional. Without this tool, a warning is issued at make.
-- warning record:

Warning: Bison executables not found in PATH
-- required later to configure the mysql service when it starts.
----shell:~$ sudo apt-get install chkconfig
= > mysql installation:
1. Extract the source code file
--shell is located in the directory where the source files reside
- decompression
shell:~$ tar zxvf mysql-5.5.8.tar.gz
2. cmake operation
--shell location to the extracted source code folder directory (folder: mysql-5.5.8)
- cmake executed:
shell:~$ cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
Note: no line feed. On official documents, the cmake command is followed by a dot that doesn't make sense. Adding a command here won't work
Source code configuration options:
//mysql installed home directory, version 5.5.8 defaults to /usr/local/mysql, so you can not add

//mysql data save path, custom

//mysql profile address --The default my. cnf option file directory

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

//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

// the listening port of the database server TCP/IP connection is 3306 by default

//Whether to enable LOCAL capability in the client library for LOAD DATA INFILE
// turned off by default, turned on here

// database encoding Settings
3. Compile and install
-- locate shell to the source folder directory
-- execution :(it took about 20 minutes to compile)
shell:~$ make
shell:~$ make install

4. Subsequent configuration
-- go to the scripts directory under the mysql installation directory
shell:~$ cd /usr/local/mysql/scripts
-- generate the new MySQL authorization table using the mysql_install_db script
./mysql_install_db --basedir=/usr/local/mysql --datadir=/home/system_username/Programming/mysql/mysqldata
-- go to the supported files 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 the service file and modify it
shell:~$ sudo cp mysql.server mysqld
- modify mysqld
mv mysqld /etc/init.d/mysqld
-- start the service
shell:~$ service mysqld start
-- shut down service
shell:~$ service mysqld stop
service command:
1. Commands for managing services in the Linux system
2. The function is to go to /etc/ init. d directory to find the corresponding service, to open and close the operation
3. After the above operation, the mysqld service file corresponds to the mysql.server file
-- add a service to the self-starting item
shell:~$ sudo chkconfig --level 3 mysqld on

-- set up the soft connection so that the three commands mysql, mysqldump, mysqladmin can run directly 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 code solution:
1. Scrambled code analysis
-- enter mysql from terminal shell
shell:~$ mysql
mysql > show variables like '%character%'
-- get 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 the encoding of character_set_database, character_set_server is still the default latin1.
For some reason, DEFAULT_CHARSET was set to utf8, which didn't seem to work. View official documents
Found that character_set_database does not support configuration file (/etc/ my.cnf) variable Settings,
But character_set_server supports configuration file variable Settings.

2. Solutions
-- open the configuration file
shell:~$ sudo gedit /etc/my.cnf
Then add it under the [mysqld] configuration option
character-set-server = utf8
-- then go to mysql
mysql > show variables like '%character%'
Result: character_set_database, character_set_server both become utf8
- test:
Insert the Chinese field into the database table and the Chinese will be displayed normally.

Note: 1. When using version 5.1, the following methods can solve the Chinese coding problem
-- add: default-character-set = utf8 under sections [mysqld] and [client], respectively
2. I don't know whether it is because of manual compilation or not, 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/ ended
[ERROR] /usr/local/mysql/bin/mysqld: unknown variable 'default-character-set=utf8'
[ERROR] Aborting
-- this will cause the pid file (datadir/ not to be updated
-- remove the configuration files [mysqld] and [client] : default-character-set = utf8, and the database service starts normally

Related articles: