In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
The main content of this article is "introduction to the method of installing MySQL source code". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn the "MySQL source code installation method introduction" bar!
There are three types of MYSQL installation: command line installation, binary installation and source code installation.
Command line installation is relatively simple, so let's not make too much statement. Today we will focus on the source code installation of MYSQL.
Compilation and installation process description:
1. Download the source code
two。 Check whether the dependency packages required for source code compilation are complete
3. Decompress and compile
4.make & & make install
5. Initialize the data directory
6. Database permissions settin
7. Define the startup mode
General conventions for software installation:
The software installation package is placed under / usr/local/src
The software root directory basedir is under / usr/local/xxx, such as / usr/local/mysql
The configuration file is under / etc/, such as / etc/my.cnf
The data directory datadir is usually placed on a separate disk
The mysql service is named mysqld
=
Prepare for
=
# create a data directory
[root@xxx ~] # mkdir / data/mysql
# create a root directory
[root@xxx ~] # mkdir / usr/local/mysqlrp
# enter the software storage directory
[root@xxx ~] # cd / usr/local/src/
[root@xxx src] # mv / root/mysql-5.6.24.tar.gz.
[root@xxx src] # tar-zxvf mysql-5.6.24.tar.gz
[root@xxx src] # cd mysql-5.6.24
# check whether cmake is installed. If not, use yum install cmake or other methods to install it
[root@xxx mysql-5.6.24] # which cmake
/ usr/bin/cmake
# install the prerequisite dependency packages
[root@xxx mysql-5.6.24] # yum install ncurses-devel
[root@xxx mysql-5.6.24] # yum install bison
# =
Compile
# =
Cmake\
-DCMAKE_INSTALL_PREFIX=/usr/local/mysqlrp\
-DMYSQL_DATADIR=/data/mysql\
-DSYSCONFDIR=/etc\
-DWITH_MYISAM_STORAGE_ENGINE=1\
-DWITH_INNOBASE_STORAGE_ENGINE=1\
-DWITH_READLINE=1\
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock\
-DMYSQL_TCP_PORT=3306\
-DENABLED_LOCAL_INFILE=1\
-DWITH_PARTITION_STORAGE_ENGINE=1\
-DEXTRA_CHARSETS=all\
-DDEFAULT_CHARSET=utf8\
-DDEFAULT_COLLATION=utf8_general_ci
[root@xxx mysql-5.6.24] # ls / usr/local/mysqlrp/
[root@xxx mysql-5.6.24] #
[root@xxx mysql-5.6.24] # ls / data/mysql/
[root@xxx mysql-5.6.24] #
[root@xxx mysql-5.6.24] # make
[root@xxx mysql-5.6.24] # ls / usr/local/mysqlrp/
[root@xxx mysql-5.6.24] # ls / data/mysql/
[root@xxx mysql-5.6.24] #
The file is generated in the root directory only when # make install
[root@xxx mysql-5.6.24] # make install
[root@xxx mysql-5.6.24] # ls / usr/local/mysqlrp/
Bin data include lib mysql-test scripts sql-bench
COPYING docs INSTALL-BINARY man README share support-files
[root@xxx mysql-5.6.24] # ls / data/mysql/
[root@xxx mysql-5.6.24] #
[root@xxx mysql-5.6.24] # cd / usr/local/mysqlrp/
# create mysql to manage users and groups
[root@xxx mysqlrp] # groupadd mysql
[root@xxx mysqlrp] # useradd mysql-g mysql
# modify the configuration file, modify the location of the root directory and data directory.
[root@xxx local] # vi / etc/my.cnf
...
[mysqld]
Basedir=/usr/local/mysqlrp
Datadir=/data/mysql
# initialize the data directory
[root@xxx mysqlrp] # / scripts/mysql_install_db-- user=mysql-- defaults-file=/etc/my.cnf &
# create mysql service mysqld
[root@xxx mysqlrp] # cp support-files/mysql.server / etc/init.d/mysqld
# modify the corresponding permissions of each directory
[root@xxx mysqlrp] # chown-R mysql.mysql / usr/local/mysqlrp
[root@xxx mysqlrp] # chown-R mysql.mysql / data/mysql
[root@xxx mysqlrp] # chown mysql.mysql / etc/my.cnf
[root@xxx mysqlrp] # chown mysql.mysql / etc/init.d/mysqld
[root@xxx mysqlrp] # chmod-R 755 / usr/local/mysqlrp
[root@xxx mysqlrp] # chmod-R 755 / data/mysql
Root@xxx mysqlrp] # chmod 644 / etc/my.cnf
[root@xxx mysqlrp] # chmod 755 / etc/init.d/mysqld
# start the mysql service
[root@xxx local] # service mysqld start
Starting MySQL.
[OK]
# =
# Common dependency packages for source code compilation
# =
Kernel-headers-2.6.32-358.el6.x86_64.rpm
Glibc-headers-2.12-1.107.el6.x86_64.rpm
Glibc-devel-2.12-1.107.el6.x86_64.rpm
Cpp-4.4.7-3.el6.x86_64.rpm
Gcc-4.4.7-3.el6.x86_64.rpm
Libstdc++-devel-4.4.7-3.el6.x86_64.rpm
Gcc-c++-4.4.7-3.el6.x86_64.rpm
Autoconf-2.63-5.1.el6.noarch.rpm
Automake-1.11.1-4.el6.noarch.rpm
Zlib-1.2.3-29.el6.x86_64.rpm
Ncurses-devel-5.7-3.20090208.el6.x86_64.rpm
Libgcrypt-1.4.5-9.el6_2.2.x86_64.rpm
Libtool-2.2.6-15.5.el6.x86_64.rpm
Bison-2.4.1-5.el6.x86_64.rpm
# =
# 2 experiments are attached to explain frequently asked questions
# Lab 1 shows that when initializing a data directory, you must initialize the directory under the root directory basedir (the specific data directory can be customized) and initialize it with an initialization script.
# experiment 2 shows that the database will modify the contents of the source code during compilation, such as src/mysql-5.6.24/support-files/mysql.server, and change the root directory to the root directory specified at the time of compilation
# specify a data directory when the database is compiled. After installation, the mysql tool does not specify a data directory and there is no data directory in the root directory. The data directory specified at compile time will be preferred as your own data directory.
# =
Click (here) to collapse or open
# =
# Lab 1
# =
[root@xxx mysqlrp] # mkdir / tmp/test
# =
# enter the temporary directory for testing and initialize the data directory
# =
[root@xxx mysqlrp] # cd / tmp/test/
[root@xxx test] # / usr/local/mysqlrp/scripts/mysql_install_db-- user=mysql &
[1] 36700
[root@xxx test] # FATAL ERROR: Could not find. / bin/my_print_defaults
If you compiled from source, you need to run 'make install' to
Copy the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top
Level of the extracted archive, or pass the-- basedir option
Pointing to that location.
[1] + Exit 1 / usr/local/mysqlrp/scripts/mysql_install_db-user=mysql
[root@xxx test] # / usr/local/mysqlrp/scripts/mysql_install_db-user=mysql-datadir=/data/mysql &
[1] 36704
[root@xxx test] # FATAL ERROR: Could not find. / bin/my_print_defaults
If you compiled from source, you need to run 'make install' to
Opy the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top
Level of the extracted archive, or pass the-- basedir option
Pointing to that location.
[1] + Exit 1 / usr/local/mysqlrp/scripts/mysql_install_db-user=mysql-datadir=/data/mysql
[root@xxx test] # / usr/local/mysqlrp/scripts/mysql_install_db-user=mysql-basedir=/usr/local/mysqlrp-datadir=/data/mysql &
# =
# initialization is successful after specifying the root directory
# =
[root@xxx mysqlrp] # cp support-files/mysql.server / etc/init.d/mysqld
[root@xxx mysqlrp] # chown-R mysql.mysql / usr/local/mysql
[root@xxx mysqlrp] # chown-R mysql.mysql / data/mysql/
[root@xxx mysqlrp] # mkdir log
[root@xxx mysqlrp] # chown-R mysql.mysql log
[root@xxx mysqlrp] # / bin/mysqld_safe-- user=mysql &
[1] 37694
[root@xxx mysqlrp] # 151113 15:45:58 mysqld_safe Logging to'/ data/mysql/zc-appname-ip-ip.err'.
151113 15:45:59 mysqld_safe Starting mysqld daemon with databases from / data/mysql
151113 15:45:59 mysqld_safe mysqld from pid file / data/mysql/zc-appname-ip-ip.pid ended
[1] + Done. / bin/mysqld_safe-user=mysql
[root@xxx mysqlrp] # ps-ef | grep mysql
Root 37847 12729 0 15:46 pts/3 00:00:00 grep mysql
# =
# attempt to start, failed
# =
[root@xxx local] # mv mysqlrp/ mysql
[root@xxx mysqlrp] # chown-R mysql.mysql / usr/local/mysql
[root@xxx local] # mv mysql/ mysqlrp
[root@xxx local] # service mysqld start
Starting MySQL.The server quit without updating PID file (/ data/mysql/zc-appname-ip-ip.pid). [FAILED]
# =
# attempt to start, failed
# =
[root@xxx local] # cd mysqlrp/
[root@xxx mysqlrp] #. / bin/mysqld
Mysqld mysqld_multi mysqld_safe mysqldump mysqldumpslow
[root@xxx mysqlrp] #. / bin/mysqld_safe-user=mysql&
[1] 38052
[root@xxx mysqlrp] # 151113 15:49:31 mysqld_safe Logging to'/ data/mysql/zc-appname-ip-ip.err'.
151113 15:49:31 mysqld_safe Starting mysqld daemon with databases from / data/mysql
151113 15:49:32 mysqld_safe mysqld from pid file / data/mysql/zc-appname-ip-ip.pid ended
[1] + Done. / bin/mysqld_safe-user=mysql
[root@xxx mysqlrp] # ps-ef | grep mysql
Root 38205 12729 0 15:49 pts/3 00:00:00 grep mysql
# =
# attempt to start, failed
# =
[root@xxx mysqlrp] # / scripts/mysql_install_db-- user=mysql-- datadir=/data/mysql/ &
# =
# initialized data directory successfully
# =
[root@xxx mysqlrp] # / scripts/mysql_install_db-- user=mysql-- datadir=/usr/local/mysqlrp/data/ &
# =
# initialize the data directory again, successfully
# =
[root@xxx mysqlrp] # / bin/mysqld_safe-- user=mysql &
[1] 38312
[root@xxx mysqlrp] # 151113 15:56:03 mysqld_safe Logging to'/ usr/local/mysqlrp/data/zc-appname-ip-ip.err'.
151113 15:56:03 mysqld_safe Starting mysqld daemon with databases from / usr/local/mysqlrp/data
[root@xxx mysqlrp] # ps-ef | grep mysql
Root 38312 12729 0 15:56 pts/3 00:00:00 / bin/sh. / bin/mysqld_safe-- user=mysql
Mysql 38441 38312 3 15:56 pts/3 00:00:00 / usr/local/mysqlrp/bin/mysqld-basedir=/usr/local/mysqlrp-datadir=/usr/local/mysqlrp/data-plugin-dir=/usr/local/mysqlrp/lib/plugin-user=mysql-log-error=/usr/local/mysqlrp/data/zc-appname-ip-ip.err-pid-file=/usr/local/mysqlrp/data/zc-appname-ip-ip.pid-socket=/tmp/mysql.sock
Root 38465 12729 0 15:56 pts/3 00:00:00 grep mysql
# =
# attempt to start, successful
# =
# =
# Lab 2
# =
[root@xxx mysqlrp] # 151113 15:56:43 mysqld_safe mysqld from pid file / usr/local/mysqlrp/data/zc-appname-ip-ip.pid ended
Ps
PID TTY TIME CMD
12729 pts/3 00:00:00 bash
38471 pts/3 00:00:00 ps
[1] + Done. / bin/mysqld_safe-user=mysql
[root@xxx mysqlrp] # ps-ef | grep mysql
Root 38473 12729 0 15:56 pts/3 00:00:00 grep mysql
[root@xxx mysqlrp] # service mysqld start
Starting MySQL.The server quit without updating PID file (/ [FAILED] ql/zc-appname-ip-ip.pid).
[root@xxx mysqlrp] #
[root@xxx local] # cp src/mysql-5.6.24/support-files/mysql.server / etc/init.d/mysqldcp: overwrite `/ etc/init.d/mysqld'? Y
[root@xxx local] # service mysqld start
/ etc/init.d/mysqld: line 256: my_print_defaults: command not found
/ etc/init.d/mysqld: line 276: cd: / usr/local/mysqlrp: No such file or directory
Starting MySQLCouldn't find MySQL server (/ usr/local/ mysqlr [failed] sqld_safe)
[root@xxx local] # mv mysql mysqlrp
[root@xxx local] # service mysqld start
Starting MySQL.The server quit without updating PID file (/ [FAILED] ql/zc-appname-ip-ip.pid).
[root@xxx local] # vi / etc/my.cnf
Datadir=xxxx
[root@xxx local] # service mysqld start
Starting MySQL.
[OK]
At this point, I believe that everyone on the "MySQL source code installation method introduction" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.