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

How to install and configure the source code version of MySQL under Linux

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

Share

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

This article mainly shows you "Linux how to install and configure the source code version of MySQL", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn how to install and configure the source code version of MySQL under Linux "this article.

Operating system version: Red Hat Enterprise Linux Server release 5 (Tikanga)

MySQL version:

Installation file: MySQL-community-5.1.45-1.rhel5.src.rpm

1. Release the source code package

The installation file used is a source RPM, and its contents should be released first:

Method 1:

[root@redhat5-db-1 software] # rpm-I MySQL-community-5.1.45-1.rhel5.src.rpm

Error: cannot create% sourcedir / usr/src/redhat/SOURCES

[root@redhat5-db-1 software] # mkdir-p / usr/src/redhat/SOURCES

[root@redhat5-db-1 software] # rpm-I MySQL-community-5.1.45-1.rhel5.src.rpm

Warning: user mysqldev does not exist-using root

Warning: group mysqldev does not exist-using root

Warning: user mysqldev does not exist-using root

Warning: group mysqldev does not exist-using root

[root@redhat5-db-1 software] # ls / usr/src/redhat/*

/ usr/src/redhat/SOURCES:

Mysql-5.1.45.tar.gz

/ usr/src/redhat/SPECS:

Mysql-5.1.45.rhel5.spec

[@ more@] method 2:

[root@redhat5-db-1 software] # rpm2cpio MySQL-community-5.1.45-1.rhel5.src.rpm | cpio-idmv

Mysql-5.1.45.rhel5.spec

Mysql-5.1.45.tar.gz

43995 blocks

[root@redhat5-db-1 software] # ls

Mysql-5.1.45.rhel5.spec mysql-5.1.45.tar.gz MySQL-community-5.1.45-1.rhel5.src.rpm

Note: no matter which method is used, another file, mysql-5.1.45.rhel5.spec, will be released while the source code package is released. It is a RPM SPEC file that can be used to create MySQL source code files or binaries with the rpmbuild command (the-bp option creates the source code file in the / usr/src/redhat/BUILD directory, and the-bb option creates the binary program in the / usr/src/redhat/RPM directory), which is not discussed here.

two。 Preparation before installation

1) create users and groups

[root@redhat5-db-1 software] # groupadd mysql

[root@redhat5-db-1 software] # useradd-g mysql mysql

[root@redhat5-db-1 software] # id mysql

Uid=502 (mysql) gid=504 (mysql) groups=504 (mysql)

2) prepare the necessary catalogue

[root@redhat5-db-1 software] # mkdir-p / opt/mysql / data/mysql

[root@redhat5-db-1 software] # chown mysql:mysql / opt/mysql / data/mysql

3) install the necessary RPM

Ncurses-devel needs to be installed, otherwise the following error will be reported at compile time:

Checking for termcap functions library... Configure: error: No curses/termcap library found

Locate the RPM on the Red Hat EL 5 installation CD and install:

[root@redhat5-db-1 software] # mount-o ro / dev/cdrom / mnt/cdrom

[root@redhat5-db-1 software] # rpm-ivh / mnt/cdrom/Server/ncurses-devel-5.5-24.20060715.i386.rpm

Warning: / mnt/cdrom/Server/ncurses-devel-5.5-24.20060715.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186

Preparing... # [100%]

1:ncurses-devel # # [100%]

4) decompress the source code package

[root@redhat5-db-1 software] # tar-zxf mysql-5.1.45.tar.gz

[root@redhat5-db-1 software] # ls-p

Mysql-5.1.45/ mysql-5.1.45.rhel5.spec mysql-5.1.45.tar.gz MySQL-community-5.1.45-1.rhel5.src.rpm

3. Install MySQL

1) CONFIGURE

[root@redhat5-db-1 software] # su-mysql

[mysql@redhat5-db-1 ~] $cd / opt/software/mysql-5.1.45

[mysql@redhat5-db-1 mysql-5.1.45] $. / configure-- prefix=/opt/mysql-- localstatedir=/data/mysql-- with-plugins=innobase

Checking build system type... I686-pc-linux-gnu

Checking host system type... I686-pc-linux-gnu

Checking target system type... I686-pc-linux-gnu

Checking for a BSD-compatible install... / usr/bin/install-c

.

Config.status: executing depfiles commands

Config.status: executing libtool commands

/ bin/rm: cannot remove `libtoolT': No such file or directory

Config.status: executing default commands

Thank you for choosing MySQL!

Remember to check the platform specific part of the reference manual

For hints about installing MySQL on your platform.

Also have a look at the files in the Docs directory.

Note: the-- prefix option specifies the path to the MySQL program;-- the localstatedir option specifies the path to the MySQL data file; and-- with-plugins=innobase specifies that the MySQL server contains the InnoDB function.

2) MAKE

[mysql@redhat5-db-1 mysql-5.1.45] $make

Making all in.

Make [1]: Entering directory `/ opt/software/mysql-5.1.45'

Make abi_headers= "include/mysql/plugin.h include/mysql.h" do_abi_check

Make [2]: Entering directory `/ opt/software/mysql-5.1.45'

.

Making all in win

Make [1]: Entering directory `/ opt/software/mysql-5.1.45/win'

Make [1]: Nothing to be done for `all'.

Make [1]: Leaving directory `/ opt/software/mysql-5.1.45/win'

3) MAKE-INSTALL

[mysql@redhat5-db-1 mysql-5.1.45] $make install

Making install in.

Make [1]: Entering directory `/ opt/software/mysql-5.1.45'

Make abi_headers= "include/mysql/plugin.h include/mysql.h" do_abi_check

Make [2]: Entering directory `/ opt/software/mysql-5.1.45'

.

Making install in win

Make [1]: Entering directory `/ opt/software/mysql-5.1.45/win'

Make [2]: Entering directory `/ opt/software/mysql-5.1.45/win'

Make [2]: Nothing to be done for `install-exec-am'.

Make [2]: Nothing to be done for `install-data-am'.

Make [2]: Leaving directory `/ opt/software/mysql-5.1.45/win'

Make [1]: Leaving directory `/ opt/software/mysql-5.1.45/win'

[mysql@redhat5-db-1 mysql-5.1.45] $ls / opt/mysql

Bin docs include lib libexec mysql-test share sql-bench

4. Work after installation

1) create options file

[root@redhat5-db-1 ~] # cp / opt/software/mysql-5.1.45/support-files/my-medium.cnf / etc/my.cnf

[root@redhat5-db-1 ~] # chown mysql:mysql / etc/my.cnf

The MySQL server can be configured by modifying its contents. Here, simply uncomment the line where the InnoDB-related parameters are located:

# Uncomment the following if you are using InnoDB tables

Innodb_data_home_dir = / data/mysql/

Innodb_data_file_path = ibdata1:10M:autoextend

Innodb_log_group_home_dir = / data/mysql/

# You can set.. _ buffer_pool_size up to 50-80%

# of RAM but beware of setting memory usage too high

Innodb_buffer_pool_size = 16m

Innodb_additional_mem_pool_size = 2m

# Set.. _ log_file_size to 25% of buffer pool size

Innodb_log_file_size = 5m

Innodb_log_buffer_size = 8m

Innodb_flush_log_at_trx_commit = 1

Innodb_lock_wait_timeout = 50

2) set environment variables

Add the following to the. bash_profile file under the HOME directory of mysql

# Added by ggyy on March 31st, 2010

PATH=$PATH:/opt/mysql/bin

Export PATH

3) initialize MySQL

[mysql@redhat5-db-1 ~] $/ opt/mysql/bin/mysql_install_db

Installing MySQL system tables...

100331 18:21:59 [Warning]'--skip-locking' is deprecated and will be removed in a future release. Please use'--skip-external-locking' instead.

OK

Filling help tables...

100331 18:22:00 [Warning]'--skip-locking' is deprecated and will be removed in a future release. Please use'--skip-external-locking' instead.

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:

/ opt/mysql/bin/mysqladmin-u root password' new-password'

/ opt/mysql/bin/mysqladmin-u root-h redhat5-db-1 password' new-password'

Alternatively you can run:

/ opt/mysql/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 / opt/mysql; / opt/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

Cd / opt/mysql/mysql-test; perl mysql-test-run.pl

Please report any problems with the / opt/mysql/bin/mysqlbug script!

[mysql@redhat5-db-1 ~] $ls / data/mysql

Mysql mysql-bin.000001 mysql-bin.000002 mysql-bin.index test

3) start and shut down MySQL

Start the MySQL server and test the login:

[mysql@redhat5-db-1 ~] $/ opt/mysql/bin/mysqld_safe &

[1] 3028

[mysql@redhat5-db-1] $100331 18:27:18 mysqld_safe Logging to'/ data/mysql/redhat5-db-1.err'.

100331 18:27:18 mysqld_safe Starting mysqld daemon with databases from / data/mysql

Mysql > select version ()

+-+

| | version () |

+-+

| | 5.1.45-log |

+-+

1 row in set (0.00 sec)

Mysql > show variables like "have_innodb"

+-+ +

| | Variable_name | Value |

+-+ +

| | have_innodb | YES |

+-+ +

1 row in set (0.00 sec)

You can use the mysql.server script to start and shut down the MySQL server, which is located in the support-files subdirectory under the extracted source code directory. There are many other useful files and scripts in this directory, which you can consider copying to the MySQL program directory and adding the corresponding path to PATH in the .bash _ profile file.

[mysql@redhat5-db-1 ~] $cp-pr / opt/software/mysql-5.1.45/support-files / opt/mysql

[mysql@redhat5-db-1 ~] $chmod uplix / opt/mysql/support-files/mysql.server

[mysql@redhat5-db-1 ~] $which mysql.server

/ opt/mysql/support-files/mysql.server

[mysql@redhat5-db-1 ~] $mysql.server stop

Shutting down MySQL.100331 18:58:49 mysqld_safe mysqld from pid file / data/mysql/redhat5-db-1.pid ended

[OK]

The above is all the contents of the article "how to install and configure the source code version of MySQL under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more 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