Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of MySQL Source Code installation

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the example analysis of MySQL source code installation, the article is very detailed, has a certain reference value, interested friends must read it!

Operating system: CentOS 6.7

MySQL version: 5.6.30

1. Preparation in advance

2. System configuration

3.CMake compilation configuration

4.make & & make install

5. Post-configuration and testing

Reference

1. Preparation in advance

First of all, you need CMake, which can be installed directly by yum:

Yum install cmake

You can also download the source code to compile on the official website https://cmake.org/.

I chose the official website to download the latest version of cmake-3.5.2.tar.gz.

# tar-zxvf cmake-3.5.2.tar.gz & & cd cmake-3.5.2

#. / configure

Part of the output is slightly.

-- Build files have been written to: / soft/cmake-3.5.2

-

CMake has bootstrapped. Now run gmake.

# gmake

# make install

two。 System configuration

Add groups and users:

Groupadd mysql

Useradd-g mysql mysql

Add at the end of the vi / etc/security/limits.conf file:

Mysql soft nproc 2047

Mysql hard nproc 16384

Mysql soft nofile 1024

Mysql hard nofile 65536

3.CMake compilation configuration

Decompress the source package:

Tar zxvf mysql-5.6.30.tar.gz & & cd mysql-5.6.30

CMake compilation configuration

Cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql\

-DDEFAULT_CHARSET=utf8\

-DDEFAULT_COLLATION=utf8_general_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_PARTITION_STORAGE_ENGINE=1\

-DWITH_PERFSCHEMA_STORAGE_ENGINE=1\

-DCOMPILATION_COMMENT='JSS for mysqltest'\

-DWITH_READLINE=ON\

-DSYSCONFDIR=/data/mysqldata/3306\

-DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock

The following error was encountered

-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)

CMake Error at cmake/readline.cmake:85 (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:128 (FIND_CURSES)

Cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE)

CMakeLists.txt:421 (MYSQL_CHECK_EDITLINE)

Configuring incomplete, errors occurred!

See also "/ soft/mysql-5.6.30/CMakeFiles/CMakeOutput.log".

See also "/ soft/mysql-5.6.30/CMakeFiles/CMakeError.log".

[root@JY-DB mysql-5.6.30] #

Yum installation prompts missing packages:

Yum install ncurses-devel

Re-delete the profile:

Rm-rf CMakeCache.txt

Then recompile the CMake tool:

CMake Warning:

Manually-specified variables were not used by the project:

WITH_READLINE

-- Build files have been written to: / soft/mysql-5.6.30

[root@JY-DB mysql-5.6.30] #

4.make & & make install

[root@JY-DB mysql-5.6.30] # make & & make install

A large amount of output is slightly.

This time will be longer, and it also has something to do with the performance of the machine.

5. Post-configuration and testing

5.1 package the binary version of MySQL:

[root@JY-DB data] # tar zcvf mysql-5.6.30.tar.gz / usr/local/mysql/

5.2 modify the owner of the directory where the MySQL software resides:

Chown-R mysql.mysql / usr/local/mysql

5.3 modify mysql user environment variables:

Vi / .bash_profile

Export LANG=zh_CN.GB18030

Export PATH=/usr/local/mysql/bin:$PATH

5.4 create a database service:

# mkdir-p / data/mysqldata/ {3306 / {data,tmp,binlog}, backup,scripts}

# chown-R mysql.mysql / data/mysqldata

# su-mysql

$more / usr/local/mysql/support-files/my-default.cnf

$vi / data/mysqldata/3306/my.cnf

The my.cnf configuration file is as follows:

[client]

Port = 3306

Socket = / data/mysqldata/3306/mysql.sock

# The MySQL Server

[mysqld]

Port = 3306

User = mysql

Socket = / data/mysqldata/3306/mysql.sock

Pid-file = / data/mysqldata/3306/mysql.pid

Basedir = / usr/local/mysql

Datadir = / data/mysqldata/3306/data

Tmpdir = / data/mysqldata/3306/tmp

Open_files_limit = 10240

Explicit_defaults_for_timestamp

Sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

# Buffer

Max_allowed_packet = 256m

Max_heap_table_size = 256m

Net_buffer_length = 8k

Sort_buffer_size = 2m

Join_buffer_size = 4m

Read_buffer_size = 2m

Read_rnd_buffer_size = 16m

# Log

Log-bin = / data/mysqldata/3306/binlog/mysql-bin

Binlog_cache_size = 32m

Max_binlog_cache_size = 512m

Max_binlog_size = 512m

Binlog_format = mixed

Log_output = FILE

Log-error =.. / mysql-error.log

Slow_query_log = 1

Slow_query_log_file =.. / slow_query.log

General_log = 0

General_log_file =.. / general_query.log

Expire-logs-days = 14

# InnoDB

Innodb_data_file_path = ibdata1:2048M:autoextend

Innodb_log_file_size = 256m

Innodb_log_files_in_group = 3

Innodb_buffer_pool_size = 1024m

[mysql]

No-auto-rehash

Prompt = (\ u @\ h) [\ d] >\ _

Default-character-set = gbk

Initialize the MySQL database:

$/ usr/local/mysql/scripts/mysql_install_db-datadir=/data/mysqldata/3306/data-basedir=/usr/local/mysql

5.5 start the database service:

Mysqld_safe-- defaults-file=/data/mysqldata/3306/my.cnf &

Test the connection and view the MySQL process and port listening status:

Netstat-lnt | grep 3306

Ps-ef | grep bin/mysql | grep-v grep

The actual operation process is as follows:

[root@JY-DB ~] # su-mysql

[mysql@JY-DB ~] $mysql

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 1

Server version: 5.6.30-log JSS for mysqltest

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

(root@localhost) [(none)] > exit

Bye

[mysql@JY-DB ~] $netstat-lnt | grep 3306

Tcp 0 0: 3306: * LISTEN

[mysql@JY-DB ~] $

[mysql@JY-DB ~] $ps-ef | grep bin/mysql | grep-v grep

Mysql 6736 1753 0 11:24 pts/0 00:00:00 / bin/sh / usr/local/mysql/bin/mysqld_safe-- defaults-file=/data/mysqldata/3306/my.cnf

Mysql 7202 6736 0 11:24 pts/0 00:00:00 / usr/local/mysql/bin/mysqld-defaults-file=/data/mysqldata/3306/my.cnf-basedir=/usr/local/mysql-datadir=/data/mysqldata/3306/data-plugin-dir=/usr/local/mysql/lib/plugin-log-error=/data/mysqldata/3306/data/../mysql-error.log-open-files-limit=10240-pid-file=/data/mysqldata/3306/mysql.pid- -socket=/data/mysqldata/3306/mysql.sock-- port=3306

The above is all the contents of the article "sample Analysis of MySQL Source installation". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report