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

MySQL5.5 source code installation process

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly explains the "MySQL5.5 source code installation process", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "MySQL5.5 source code installation process" bar!

System requirements for source code installation:

The source installation of MySQL requires some of the following development tools.

CMake is used to build frameworks on all platforms

Excellent make program. GNU make 3.75 or later is recommended.

ANSI C++ Editor. GCC 4.2.1 or later, Sun Studio 12 or later, Visual Studio 2008 or later.

Enough memory is required. If you are compiling a large source file Times "internal compiler error", it may be that the system's memory is too small.

If you want to run the test script, you need to install Perl. Most Unix-like systems include Perl. On Windows systems, you can install ActiveState Perl.

Install the required packages

[root@localhost ~] # yum install gcc-c++

[root@localhost ~] # yum install libaio-devel

[root@localhost ~] # yum install ncurses-devel

[root@localhost ~] # yum install numactl-devel

[root@localhost ~] # yum install openssl-devel

[root@localhost ~] # yum install gperf

Install the rpm-build package

[root@localhost yum.repos.d] # yum install rpm-build

Install cmake2.8.2

Go to https://cmake.org/download/ to download the cmake source installation package

[root@localhost install] # wget http://www.cmake.org/files/v2.8/cmake-2.8.2.tar.gz-- no-check-certificate

Decompression

[root@localhost install] # gzip-d cmake-2.8.2.tar.gz

[root@localhost install] # tar fvx cmake-2.8.2.tar

[root@localhost install] # cd cmake-2.8.2

[root@localhost cmake-2.8.2] #. / bootstrap

Compilation and installation

[root@localhost cmake-2.8.2] # make

[root@localhost cmake-2.8.2] # make install

View version

[root@localhost cmake-2.8.2] # cmake- version

Cmake version 2.8.2

If you create a binary rpm installation file, generate it with the following command

[root@localhost install] # rpmbuild-rebuild-clean MySQL-5.5.48-1.el6.src.rpm-define='runselftest 0'

View the generated RPM file

[root@localhost x86_64] # cd / root/rpmbuild/RPMS/x86_64

[root@localhost x86_64] # ll

Total 142788

-rw-r--r--. 1 root root 15333376 Mar 28 23:11 MySQL-client-5.5.48-1.linux2.6.x86_64.rpm

-rw-r--r--. 1 root root 4992448 Mar 28 23:12 MySQL-devel-5.5.48-1.linux2.6.x86_64.rpm

-rw-r--r--. 1 root root 51994352 Mar 28 23:12 MySQL-embedded-5.5.48-1.linux2.6.x86_64.rpm

-rw-r--r--. 1 root root 39075180 Mar 28 23:11 MySQL-server-5.5.48-1.linux2.6.x86_64.rpm

-rw-r--r--. 1 root root 1753148 Mar 28 23:12 MySQL-shared-5.5.48-1.linux2.6.x86_64.rpm

-rw-r--r--. 1 root root 33055692 Mar 28 23:12 MySQL-test-5.5.48-1.linux2.6.x86_64.rpm

If you install it in compiled source code, execute the following command

[root@localhost install] # rpm-ivh MySQL-5.5.48-1.el6.src.rpm

Warning: MySQL-5.5.48-1.el6.src.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

1:MySQL # # [100%]

Manually create Mysql users and groups

[root@localhost install] # groupadd mysql

[root@localhost install] # useradd-r-g mysql-s / bin/false mysql

Extract the generated package

[root@localhost SOURCES] # cd / root/rpmbuild

[root@localhost rpmbuild] # ls-trl

Total 24

Drwxr-xr-x. 2 root root 4096 Mar 28 05:02 SRPMS

Drwxr-xr-x. 3 root root 4096 Mar 28 23:11 RPMS

Drwxr-xr-x. 2 root root 4096 Mar 28 23:12 BUILDROOT

Drwxr-xr-x. 2 root root 4096 Mar 28 23:12 BUILD

Drwxr-xr-x. 2 root root 4096 Mar 28 23:41 SPECS

Drwxr-xr-x. 3 root root 4096 Mar 28 23:46 SOURCES

[root@localhost rpmbuild] # cd SOURCES/

[root@localhost SOURCES] # ls-trl

Total 20712

-rw-r--r--. 1 root root 21201193 Jan 14 18:48 mysql-5.5.48.tar.gz

[root@localhost SOURCES] # tar zxvf mysql-5.5.48.tar.gz

Start compilation

[root@localhost SOURCES] # ll

Total 20712

Drwxr-xr-x. 31 7161 wheel 4096 Jan 14 18:47 mysql-5.5.48

-rw-r--r--. 1 root root 21201193 Jan 14 18:48 mysql-5.5.48.tar.gz

[root@localhost SOURCES] # cd mysql-5.5.48

[root@localhost mysql-5.5.48] # cmake. -DCMAKE_INSTALL_PREFIX=/software\

-DDEFAULT_CHARSET=utf8\

-DDEFAULT_COLLATION=utf8_general_ci\

-DENABLED_LOCAL_INFILE=ON\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_FEDERATED_STORAGE_ENGINE=1\

-DWITH_ARCHIVE_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='production environment'\

-DWITH_READLINE=ON\

-DSYSCONFDIR=/software\

-DMYSQL_UNIX_ADDR=/data/mysql.sock\

-DMYSQL_DATADIR=/data

[root@localhost mysql-5.5.48] # make

Linking CXX executable mysql_tzinfo_to_sql

[100%] Built target mysql_tzinfo_to_sql

Scanning dependencies of target mysqld

[100%] Building CXX object sql/CMakeFiles/mysqld.dir/main.cc.o

Linking CXX executable mysqld

[100%] Built target mysqld

Scanning dependencies of target udf_example

[100%] Building C object sql/CMakeFiles/udf_example.dir/udf_example.c.o

Linking C shared module udf_example.so

[100%] Built target udf_example

Scanning dependencies of target my_safe_process

[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o

Linking CXX executable my_safe_process

[100%] Built target my_safe_process

[root@localhost mysql-5.5.48] # make install

-- Installing: / data/man/man1/perror.1

-- Installing: / data/man/man1/mysqld_multi.1

-- Installing: / data/man/man1/mysql_client_test_embedded.1

-- Installing: / data/man/man1/msql2mysql.1

-- Installing: / data/man/man1/mysqlman.1

-- Installing: / data/man/man1/comp_err.1

-- Installing: / data/man/man8/mysqld.8

[root@localhost software# cd / software

[root@localhost software# ll

Total 220

Drwxr-xr-x. 2 root root 4096 Mar 29 00:06 bin

-rw-r--r--. 1 root root 17987 Jan 14 18:38 COPYING

Drwxr-xr-x. 3 root root 4096 Mar 29 00:05 data

Drwxr-xr-x. 2 root root 4096 Mar 29 00:05 docs

Drwxr-xr-x. 3 root root 4096 Mar 29 00:05 include

-rw-r--r--. 1 root root 151708 Jan 14 18:47 INSTALL-BINARY

Drwxr-xr-x. 3 root root 4096 Mar 29 00:05 lib

Drwxr-xr-x. 4 root root 4096 Mar 29 00:06 man

Drwxr-xr-x. 10 root root 4096 Mar 29 00:06 mysql-test

-rw-r--r--. 1 root root 2496 Jan 14 18:38 README

Drwxr-xr-x. 2 root root 4096 Mar 29 00:06 scripts

Drwxr-xr-x. 27 root root 4096 Mar 29 00:06 share

Drwxr-xr-x. 4 root root 4096 Mar 29 00:06 sql-bench

Drwxr-xr-x. 2 root root 4096 Mar 29 00:06 support-files

Change the permissions of MySQL installation software to mysql

[root@localhost software] # chown-R mysql.

[root@localhost software] # chgrp-R mysql.

Initialize the data file path of the MySQL database and create the system table

[root@localhost data] # scripts/mysql_install_db-user=mysql-datadir=/data

Installing MySQL system tables...

160329 0:21:08 [Note]. / bin/mysqld (mysqld 5.5.48) starting as process 25151.

OK

Filling help tables...

160329 0:21:08 [Note]. / bin/mysqld (mysqld 5.5.48) starting as process 25158.

OK

To start mysqld at boot time you have to copy

Support-files/mysql.server to the right place for your system

PLEASE 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 localhost.localdomain password' new-password'

Alternatively you can run:

. / bin/mysql_secure_installation

Which will also give you the option of removing the test

Databases and anonymous user created by default. This is

Strongly 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.pl

Please report any problems at http://bugs.mysql.com/

[root@localhost software] # chown-R root.

[root@localhost software] # chown-R mysql data

[root@localhost mysql] # cp support-files/my-medium.cnf / etc/my.cnf

Cp: overwrite `/ etc/my.cnf'? Y

Start the database

An error occurred.

[root@localhost data] # / bin/mysqld_safe-- defaults-file=/etc/my.cnf &

[1] 1053

[root@localhost data] # 160330 01:36:51 mysqld_safe Logging to'/ var/log/mysqld.log'.

160330 01:36:51 mysqld_safe Starting mysqld daemon with databases from / var/lib/mysql

160330 01:36:52 mysqld_safe mysqld from pid file / var/run/mysqld/mysqld.pid ended

[1] + Done bin/mysqld_safe-- user=mysql

Check the error log. The reason for the error is that mysql does not have read and write access to the specified path, so the process file cannot be created.

[root@localhost data] # vim / var/log/mysqld.log

160330 1:36:52 [ERROR] / data/bin/mysqld: Can't create/write to file'/ var/run/mysqld/mysqld.pid' (Errcode: 13)

160330 1:36:52 [ERROR] Can't start server: can't create PID file: Permission denied

Create the corresponding path and authorize

[root@localhost install] # mkdir-p / var/run/mysqld/

[root@localhost install] # chown-R mysql.mysql / var/run/mysqld/

[root@localhost mysql] # cp support-files/mysql.server / etc/init.d/mysql.server

Edit configuration file

[root@localhost mysql] # vim / etc/my.cnf

[client]

Port = 3306

Socket = / data/mysql.sock

# Mysql server

[mysqld]

Port = 3306

User = mysql

Socket = / data/mysql.sock

Pid-file = / var/run/mysqld/mysqld.pid

Basedir = / software

Datadir = / data

# tmpdir =

Open_files_limit = 10240

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 = 4m

Join_buffer_size = 2m

Read_buffer_size = 2m

Read_rnd_buffer_size = 16m

# Log

Log-bin = / log/binlog/mysql-bin

Binlog_cache_size = 32m

Max_binlog_cache_size = 512m

Max_binlog_size = 512m

Binlog_format = MIXED

Log_output = FILE

Log_error = / log/err.log

Slow_query_log = 1

Slow_query_log_file = / log/slow_query.log

General_log = 0

General_log_file = / log/general_query.log

# InnoDB

Innodb_data_file_path = ibdata1:12M:autoextend

# innodb_log_file_size = 256m

# innodb_log_files_in_group = 3

Innodb_buffer_pool_size = 100m

# Character set

# character_set_server = gbk

# collation_server = gbk_bin

[mysql]

No-auto-rehash

Default-character-set = gbk

Start the MySQL database

[root@localhost data] # / bin/mysqld_safe-- defaults-file=/etc/my.cnf &

[1] 5774

[root@localhost data] # 160330 01:37:51 mysqld_safe Logging to'/ var/log/mysqld.log'.

160330 01:37:51 mysqld_safe Starting mysqld daemon with databases from / var/lib/mysql

[root@localhost data] # ps-ef | grep mysql

Root 1231 55613 0 01:37 pts/2 00:00:00 / bin/sh bin/mysqld_safe-user=mysql

Mysql 1401 1231 0 01:37 pts/2 00:00:00 / data/bin/mysqld-basedir=/data-datadir=/var/lib/mysql-plugin-

Dir=/data/lib/plugin-user=mysql-log-error=/var/log/mysqld.log-pid-file=/var/run/mysqld/mysqld.pid--

Socket=/var/lib/mysql/mysql.sock

Root 1421 55613 0 01:38 pts/2 00:00:00 grep mysql

Change root user password

[root@localhost data] #. / bin/mysqladmin-u root password 'Mysql#2015'

Delete redundant root and anonymous users from the database, leaving only one root user locally

Mysql > delete from mysql.user where (user,host) not in (select 'root','localhost')

Query OK, 4 rows affected (0.00 sec)

Change the user name of root

Mysql > update mysql.user set user='system',password=password ('Mysql#2015') where user='root'

Query OK, 1 row affected (0.09 sec)

Rows matched: 1 Changed: 1 Warnings: 0

Mysql > truncate table mysql.db

Query OK, 0 rows affected (0.00 sec)

Mysql > flush privileges

Query OK, 0 rows affected (0.00 sec)

Thank you for reading, the above is the content of "MySQL5.5 source code installation process". After the study of this article, I believe you have a deeper understanding of the process of MySQL5.5 source code installation, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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