MARIADB and MySQL run concurrently on a single server

Source: Internet
Author: User
Tags stop script

[[email protected] ~]#groupadd mariadb - g Wuyi3

[email protected] ~]#useradd-u3 - g mariadb -s/sbin/nologin-d/home/< /c5>mariadb mariadb

Download the binary installation package to the/root directory from MARIADB website, this article is the latest stable version of the current mariadb-10.1.16

[Email protected] ~]# TARXVF mariadb-10.1.16-linux-x86_64.tar.gz

[Email protected] ~]# mv/root/mariadb-10.1.16-linux-x86_64/usr/local/mariadb

[email protected] ~]#mkdir-p/data/mariadb

[email protected] ~]#chown-rmariadb. /data/mariadb

[email protected] ~]#mkdir-p/log/mariadb

[email protected] ~]#chown-rmariadb. /log/mariadb

[[email protected] ~] #vi  /usr/local/mariadb/my.cnf[client]port = 3307socket =  /tmp/mariadb.sockdefault-character-set = utf8 [mysql]default-character-set =  utf8 [mysqld]port = 3307socket = /tmp/mariadb.sockbasedir = /usr/local/ Mariadbdatadir = /data/mariadbopen_files_limit = 3072back_log = 103max_ connections = 800max_connect_errors = 100000table_open_cache =  512external-locking = falsemax_allowed_packet = 32msort_buffer_size = 2mjoin_ buffer_size = 2mthread_cache_size = 51query_cache_size = 32mtmp_table_size  = 96mmax_heap_table_size = 96mslow_query_log = 1slow_query_log_file = /log/ mariadb/slow.loglog-error = /log/mariadb/error.loglong_query_time = 1server-id =  2503307log-bin = /log/mariadb/mysql-bInsync_binlog = 1binlog_cache_size = 4mmax_binlog_cache_size = 8mmax_binlog_size  = 1024Mexpire_logs_days = 60key_buffer_size = 32Mread_buffer_size =  1mread_rnd_buffer_size = 16mbulk_insert_buffer_size = 64mcharacter-set-server =  Utf8default-storage-engine = innodbbinlog_format = rowinnodb_buffer_pool_dump_at_shutdown  = 1innodb_buffer_pool_load_at_startup = 1#binlog_rows_query_log_events =  1explicit_defaults_for_timestamp = 1 transaction_isolation = repeatable-readinnodb_ additional_mem_pool_size = 16minnodb_buffer_pool_size = 512m#innodb_data_home_dir = Innodb_data_file_path = ibdata1:1024m:autoextendinnodb_flush_log_at_trx_commit = 1innodb_ log_buffer_size = 16minnodb_log_file_size = 512minnodb_log_files_in_group =  2innodb_max_dirty_pages_pct = 50innodb_file_per_table = 1innodb_locks_unsafe_for_binlog = 0wait_timeout  = 14400interactive_timeout = 14400skip-name-resolve[mysqldump]quickmax_allowed_packet  = 32m


Initializing the database

[email protected] ~]#/usr/local/mariadb/scripts/mysql_install_db--basedir=/usr/local/mariadb--datadir= /DATA/MARIADB--DEFAULTS-FILE=/USR/LOCAL/MARIADB/MY.CNF--user=mariadb


Copy the start-stop template to/etc/init.d/

[[Email protected] ~] #cp-rp/usr/local/mariadb/support-files/mysql.server/etc/init.d/mariadb


Edit the start-stop script to change the 46th, 47, 58 behavior MARIADB related directories, as shown in the following

[[email protected] ~] #vi  /etc/init.d/mariadb     46 basedir=/usr/ local/mariadb     47 datadir=/data/mariadb     48       49 # Default value, in seconds, afterwhich  the script should timeout waiting     50 # for  Server start.     51 # value here is overriden by  value in my.cnf.     52 # 0 means don ' t wait  at all     53 # Negative numbers mean to  wait indefinitely     54 service_startup_timeout=900      55      56 # lock directory for redhat  / suse.      57 lockdir= '/var/lock/subsys '      58 lock_file_path= "$ Lockdir/mariadb "


Line No. 311 Adds a unique parameter path, this article is --defaults-file=/usr/local/mariadb/my.cnf

311 $bindir/mysqld_safe--defaults-file=/usr/local/mariadb/my.cnf--datadir= "$datadir"--pid-file= "$mysqld _pid_ File_path "" [email protected] ">/dev/null 2>&1 &



[[email protected] ~]# ps -ef|grep mysqlroot     28996   2226  0 16:50 pts/2    00:00:00 grep mysql[[email  protected] ~]# /etc/init.d/mysqld startstarting mysql. success! [[email  protected] ~]# ps -ef|grep mysqlroot     29008      1  0 16:51 pts/2    00:00:00 /bin/sh /usr/ local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/he3.pidmysql     29754 29008 13 16:51 pts/2    00:00:00 /usr/local/ Mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql /lib/plugin --user=mysql --log-error=/log/mysql/error.log --open-files-limit=3072 -- Pid-file=/data/mysql/he3.pid --socket=/tmp/mysql.sock --port=3306root     29778  2226   0 16:51 pts/2    00:00:00 grep mysql



[[email protected] ~]# /usr/local/mysql/bin/mysql -uroot -p -p3306enter  password: welcome to the mysql monitor.  commands end with ;  or \g.your mysql connection id is 1server version: 5.6.25-log  MySQL Community Server  (GPL) copyright  (c)  2000, 2015, oracle and /or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or  Itsaffiliates. other names may be trademarks of their respectiveowners . type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement.mysql> select version (); +------------+| version ()   |+------------+ | 5.6.25-log |+------------+1 row in set  (0.01 sec) mysql> 





[[email protected] ~]#/etc/init.d/mariadb start

Starting MySQL success!

[[email protected] ~]# ps -ef|grep mysqlroot     29008      1  0 16:51 pts/2    00:00:00 /bin/sh  /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/he3.pidmysql     29754 29008  0 16:51 pts/2    00:00:00  /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir =/usr/local/mysql/lib/plugin --user=mysql --log-error=/log/mysql/error.log --open-files-limit= 3072 --pid-file=/data/mysql/he3.pid --socket=/tmp/mysql.sock --port=3306root      29802     1  0 16:52 pts/2     00:00:00 /bin/sh /usr/local/mariadb/bin/mysqld_safe --defaults-file=/usr/local/mariadb/my.cnf  --datadir=/data/mariadb --pid-file=/data/mariadb/he3.pidmariadb  30041 29802  7 16:52 pts/2     00:00:00 /usr/local/mariadb/bin/mysqld --defaults-file=/usr/local/mariadb/ My.cnf --basedir=/usr/local/mariadb --datadir=/data/mariadb --plugin-dir=/usr/local/mariadb/lib /plugin --user=mariadb --log-error=/log/mariadb/error.log --open-files-limit=3072 -- pid-file=/data/mariadb/he3.pid --socket=/tmp/mariadb.sock --port=3307root      30070  2226  0 16:52 pts/2    00:00:00 grep  Mysql



[Email protected] ~]#/usr/local/mariadb/bin/mysql-uroot-p-p3307enter password:welcome to the MARIADB Monitor. Commands End With; or \g.your MySQL connection ID is 11Server version:5.6.25-log mysql Community Server (GPL) Copyright (c), Oracl E, MariaDB Corporation Ab and others. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement. MariaDB [(None)]> select version (); +-----------------+| Version () |+-----------------+| 10.1.16-MARIADB |+-----------------+1 row in Set (0.00 sec)



You can also start and stop manually

Start command

[email protected]~]#/usr/local/mariadb/bin/mysqld_safe--defaults-file=/etc/mariadb.cnf--ledir=/usr/local/ Mariadb/bin--datadir=/data/mariadb &

Stop command

[Email protected] ~]#/usr/local/mariadb/bin/mysqladmin--defaults-file=/usr/local/mariadb/my.cnf-hlocalhost- P3307 shutdown


This article is from the "Age volt" blog, please make sure to keep this source http://suifu.blog.51cto.com/9167728/1834417

MARIADB and MySQL run concurrently on a single server

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.