MySQL Series installation

Source: Internet
Author: User
Tags chmod install openssl mkdir mysql version openssl stop script

Tag: The null safe parameter applies EFI profile log zlib so

5 ways to install MySQL:
1, yum/rpm installation (suitable for the requirements are not high, concurrency is not big, the company internal, some application scenarios within the enterprise)
2. Compile and install (online high concurrency service)
3, binary installation (after compiling and installing, using the own tools to package, and then copied to the same platform for installation, online high concurrency)
4. Customized RPM package, yum installation

MySQL Yum installs various versions of Yum source

http://repo.mysql.com/yum/

MySQL 4.X and 5.1.X series compilation installation
Useradd mysql-s/sbin/nologin-m

./configure \
--prefix=/application/mysql-5.1.73 \
--with-unix-socket-path=/application/mysql-5.1.73/tmp/mysql.sock \
--localstatedir=/application/mysql-5.1.73/data \
--enable-assembler \
--enable-thread-safe-client \
--with-mysqld-user=mysql \
--with-big-tables \
--without-debug \
--with-pthread \
--enable-assembler \
--with-extra-chasets=complex \
--with-readline \
--WITH-SSL \
--with-embedded-server \
--enable-local-infile \
--with-plugins=partition,innobase \
--with-myslqd-ldflags=-all-static \
--with-client-ldflags=-all-static

Make && make install

cd/application/
Ln-s Mysql-5.1.73/mysql
Mkdir-p/application/mysql/{data,tmp}
Mkdir-p/var/lib/mysql
Chown-r Mysql:mysql/application/mysql
Chown-r mysql:mysql/var/lib/mysql/

Cp-a/application/mysql/share/mysql/mysql.server/etc/init/mysqld
[-f/etc/my.cnf]&&mv/etc/my.cnf{,.ori}
Cp-a/application/mysql/share/mysql/my-small.cnf/etc/my.cnf
echo ' Export path= '/application/mysql/bin:/application/mysql/libexec:${path} ' >>/etc/profile
Source/etc/profile
which MySQL mysqld
Which mysql_install_db

mysql_install_db--basedir=/application/mysql/--datadir=/application/mysql/data/--user=mysql
/etc/init.d/mysqld start
Chkconfig mysqld on
NETSTAT-TUNLP |grep 3306
Lsof-npi

Ln-s/application/mysql/tmp/mysql.sock/var/lib/mysql/mysql.sock
Ln-s/application/mysql/tmp/mysql.sock/tmp/mysql.sock

MySQL version 5.5 and above depends on the installation
Yum install OpenSSL openssl-devel cmake* libaio* ncurses* zlib* libxml* libmcrypt* libtool*-y
Useradd mysql-s/sbin/nologin-m


MySQL 5.5.X series compilation
CMake. -dcmake_install_prefix=/application/mysql-5.5.60 \
-dmysql_datadir=/application/mysql-5.5.60/data \
-dmysql_unix_addr=/application/mysql-5.5.60/tmp/mysql.sock \
-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 \
-dwithout_partition_storage_engine=1 \
-dwith_fast_mutexes=1 \
-dwith_zlib=bundled \
-denabled_local_infile=1 \
-dwith_readline=1 \
-dwith_embedded_server=1 \
-dwith_debug=0

Make && make install


Ln-s/application/mysql-5.5.60/application/mysql
Mkdir-p/application/mysql/{data,tmp}
Chown-r mysql:mysql/application/mysql/

[-f/etc/my.cnf]&&mv/etc/my.cnf{,.ori}
Cp-a/application/mysql-5.5.60/support-files/my-small.cnf/etc/my.cnf
Cp-a/etc/my.cnf{,. ' Date +%f '}
echo ' Export Path=/application/mysql/bin:${path} ' >>/etc/profile
Source/etc/profile
which MySQL


Cd/application/mysql/scripts
./mysql_install_db--basedir=/application/mysql/--datadir=/application/mysql/data/--user=mysql
Cp/application/mysql-5.5.60/support-files/mysql.server/etc/init.d/mysqld
chmod +x/etc/init.d/mysqld
/etc/init.d/mysqld start
Chkconfig mysqld on
NETSTAT-TUNLP |grep 3306


Mkdir-p/var/lib/mysql
Chown-r Mysql:mysql/var/lib/mysql
Ln-s/application/mysql-5.5.60/tmp/mysql.sock/tmp/mysql.sock
Ln-s/application/mysql-5.5.60/tmp/mysql.sock/var/lib/mysql/mysql.sock


MySQL 5.6.X series compilation installation
Yum install OpenSSL openssl-devel cmake* libaio* ncurses* zlib* libxml* libmcrypt* libtool*-y
Useradd mysql-s/sbin/nologin-m

CMake. -dcmake_install_prefix=/application/mysql-5.6.40 \
-dmysql_datadir=/application/mysql-5.6.40/data \
-dmysql_unix_addr=/application/mysql-5.6.40/tmp/mysql.sock \
-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 \
-dwithout_partition_storage_engine=0 \
-dwith_fast_mutexes=1 \
-dwith_zlib=bundled \
-denabled_local_infile=1 \
-dwith_readline=1 \
-dwith_embedded_server=1 \
-dwith_debug=0

Make && make install

cd/application/
Ln-s Mysql-5.6.40/mysql
Mkdir-p/application/mysql/tmp
Mkdir-p/var/lib/mysql
Chown-r mysql:mysql/application/mysql/
Chown-r mysql:mysql/var/lib/mysql/
[-f/etc/my.cnf]&&mv/etc/my.cnf{,.ori}
Cp-a/application/mysql/support-files/my-default.cnf/etc/my.cnf# configuration files need to be modified manually, unlike the 5.5 series, this step is best to upload a pre-prepared configuration file
Cp-a/application/mysql/support-files/mysql.server/etc/init.d/mysqld

echo ' Export path= '/application/mysql/bin:/application/mysql/scripts:${path} ' >>/etc/profile
Source/etc/profile
which MySQL mysql_install_db

mysql_install_db--basedir=/application/mysql--datadir=/application/mysql/data--user=mysql
/etc/init.d/mysqld start
Chkconfig mysqld on
NETSTAT-TUNLP |grep mysqld

Ln-s/application/mysql/tmp/mysql.sock/var/lib/mysql/mysql.sock
Ln-s/application/mysql/tmp/mysql.sock/tmp/mysql.sock

Binary installation: The installation package name contains the Linux keyword, so-called binary installation is the installation package that can be used directly after decompression

The following is an example of 5.5.602 Binary Installation
Yum install libaio* ncurses* zlib* libxml* libmcrypt* libtool*-y
Useradd mysql-s/sbin/nologin-m

Tar xvf mysql-5.5.60-linux2.6-x86_64.tar.gz
Mkdir-p/application/mysql-5.5.60
Cp-a mysql-5.5.60-linux2.6-x86_64/*/application/mysql-5.5.60/
Cd/application
Ln-s Mysql-5.5.60/mysql


Cd/application/mysql/scripts
./mysql_install_db--basedir=/application/mysql/--datadir=/application/mysql/data/--user=mysql

Mv/etc/my.cnf{,.ori}

Cp-a/application/mysql/support-files/my-small.cnf/etc/my.cnf
Sed-i ' S#/usr/local/mysql#/application/mysql#g '/application/mysql/bin/mysqld_safe
Sed-i ' S#/usr/local/mysql#/application/mysql#g '/application/mysql/support-files/mysql.server
Cp-a/application/mysql/support-files/mysql.server/etc/init.d/mysqld

Ll/etc/init.d/mysqld

Mkdir-p/application/mysql/tmp
chmod 777/application/mysql/tmp


/etc/init.d/mysqld start
Chkconfig mysqld on

Cp-a/etc/my.cnf{,. ' Date +%f '}
echo ' Export Path=/application/mysql/bin:${path} ' >>/etc/profile
Source/etc/profile
which MySQL

Mkdir-p/var/lib/mysql
Chown-r Mysql:mysql/var/lib/mysql
Ln-s/application/mysql/tmp/mysql.sock/var/lib/mysql/mysql.sock
Netstat-tunlp|grep MySQL


Multi-Instance deployment:
1. Installation dependent

Install MySQL using a binary method (you can also use a compilation installation):
The following is an example of 5.5.602 Binary Installation
Yum install libaio* ncurses* zlib* libxml* libmcrypt* libtool*-y
Useradd mysql-s/sbin/nologin-m

Tar XF mysql-5.5.60-linux2.6-x86_64.tar.gz
Mkdir-p/application/mysql-5.5.60
Cp-a mysql-5.5.60-linux2.6-x86_64/*/application/mysql-5.5.60/
Cd/application
Ln-s Mysql-5.5.60/mysql


Mkdir-p/data/{3306,3307}/data

Import my.cnf configuration files in/data/3306 and/data/3307 directories, respectively
Note: There are a few parameters in the 2 configuration files:
Server-id
Port
Socket
Log-error
Log-bin
Relay-log
Relay_log_info_file
Slow_query_log_file
cannot be the same, where Server-id and port must not be the same
Note: You must specify the database directory as Datadir=/data/{3306,3307}/data in the/DATA/{3306,3307}/MY.CNF configuration file, the configuration file in the source package does not have this directive


Also, in the/data/3306 and/data/3307 directories, import scripts for pre-written startup services:
See separate script files for related scripts

Startup of multi-instance startup files MySQL Service essence:
Mysqld_safe--default-file =/data/3306/my.cnf &>/dev/null &
Mysqld_safe--default-file =/data/3307/my.cnf &>/dev/null &

The nature of the stop MySQL service for multi-instance startup files:
Mysql-u root-pchina123-s/data/3306/mysql.sock shutdown
Mysql-u root-pchina123-s/data/3307/mysql.sock shutdown

Chown Mysql:mysql-r/data/

Sed-i ' S#/usr/local/mysql#/application/mysql#g '/application/mysql/bin/mysqld_safe# uses the official binary package, if it is a binary package that is compiled and packaged by itself , which can be specified at compile time or not modified.

Export ' Export Path=/application/mysql/bin:${path} ' >>/etc/profile
Source/etc/profile

cd/application/mysql/scripts/#这里注意因为是多实例, so multiple initialization is required
./mysql_install_db--basedir=/application/mysql--datadir=/data/3306/data--user=mysql
./mysql_install_db--basedir=/application/mysql--datadir=/data/3307/data--user=mysql


Start two instances using the preceding startup script, respectively

Log in to the database for testing:
Msyql–uroot–pchina123-s/data/3306/mysql.sock
Msyql–uroot–pchina123-s/data/3307/mysql.sock


Note: When MySQL multi-instance local management, you must add the-s option to specify the sock file


Compile and install multiple instances: Take 5.6.40 as an example to illustrate
Yum install OpenSSL openssl-devel cmake* libaio* ncurses* zlib* libxml* libmcrypt* libtool*-y
Useradd mysql-s/sbin/nologin-m

CMake. -dcmake_install_prefix=/application/mysql-5.6.40 \
-dmysql_datadir=/application/mysql-5.6.40/data \
-dmysql_unix_addr=/application/mysql-5.6.40/tmp/mysql.sock \
-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 \
-dwithout_partition_storage_engine=0 \
-dwith_fast_mutexes=1 \
-dwith_zlib=bundled \
-denabled_local_infile=1 \
-dwith_readline=1 \
-dwith_embedded_server=1 \
-dwith_debug=0

Make && make install

cd/application/
Ln-s Mysql-5.6.40/mysql
Mkdir-p/application/mysql/tmp
Mkdir-p/var/lib/mysql
Chown-r mysql:mysql/application/mysql/
Chown-r mysql:mysql/var/lib/mysql/

Mkdir-p/data/{3306,3307}/data
Upload configuration file for 3306 instances my.cnf and start-stop script mysqld to/data/3306/directory
Upload configuration file for 3307 instances my.cnf and start-stop script mysqld to/data/3307/directory
Note: If you use the default configuration file in the source package my.cnf need to add a directive in the configuration file, datadir=/data/{3306,3307}/data specify the database location, in addition to the configuration file port configuration parameters need to be modified according to different instances


Start the service:
/data/{3306,3307}/mysqld start

Netstat-tunlp|grep MySQL

echo "/data/3306/mysqld start" >>/etc/rc.local
echo "/data/3307/mysqld start" >>/etc/rc.local

MySQL Series installation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.