Method for separate login when MariaDB and MySQL coexist

Source: Internet
Author: User

Method for separate login when MariaDB and MySQL coexist

Finally, I completed the login method when MariaDB and MySQL coexist. At that time, I knew that the installation was successful, that is, I could not log on to MariaDB. I would like to share my experiences with you.

Port Number logon method:

1. In CentOS7 Environment

1. Install Mysql5.6.19. After the installation is successful, the port number is 3306.

[Root @ centOS7] # mysql-uroot-h127.0.0.1-P3306-p

Mysql> select version ();

+ ----------- +

| Version () |

+ ----------- +

| 5.6.19 |

+ ----------- +

1 row in set (0.00 sec)

2. Install MariaDB10.0.12. after the installation is successful, Port: 3307

[Root @ centOS7] # mysql-uroot-h127.0.0.1-P3307-p

Mysql> select version ();

+ --------------------- +

| Version () |

+ --------------------- +

| 10.0.12-MariaDB-log |

+ --------------------- +

1 row in set (0.00 sec)

The following describes how to install MariaDB10.0.12 after Mysql is installed.

Download the latest binary compilation package tar.gz (currently mariadb-10.0.12-linux-x86_64) and decompress it to your custom directory. This document assumes that the installation directory is/opt.

Create the Directory and symbolic link of the data as follows:

[Root @ centOS7 opt] # mkdir mariadb-data
[Root @ centOS7 opt] # ln-s mariadb-10.0.12-linux-x86_64 mariadb
[Root @ centOS7 opt] # ls-al
Total 20
Drwxr-xr-x. 5 root 4096.
Dr-xr-x. 23 root 4096 ..
Lrwxrwxrwx. 1 root 27 mariadb-> mariadb-10.0.12-linux-x86_64
Drwxr-xr-x. 13 root 4096 mariadb-10.0.12-linux-x86_64
Drwxr-xr-x. 2 root 4096 mariadb-data

Create mariadb and mariadb, and set the permissions of the file:

[Root @ centOS7 opt] # groupadd -- system mariadb
[Root @ centOS7 opt] # useradd-c "MariaDB Server"-d/opt/mariadb-g mariadb -- system mariadb
[Root @ centOS7 opt] # chown-R mariadb: mariadb mariadb-10.0.12-linux-x86_64/
[Root @ centOS7 opt] # chown-R mariadb: mariadb-data/

Copy my. cnf from support-files and create a new my. cnf in the/opt/mariadb directory:

[Root @ centOS7 opt] # cp mariadb/support-files/my-medium.cnf mariadb-data/my. cnf
[Root @ centOS7 opt] # chown mariadb: mariadb-data/my. cnf

Edit the file/opt/mariadb-data/my. cnf: add custom values, socket, port, user, and the most important settings: data DIRECTORY and base directory. the last setting is at least as follows:

[Client]
Port = 3307
Socket =/opt/mariadb-data/mariadb. sock

[Mysqld]
Datadir =/opt/mariadb-data
Basedir =/opt/mariadb
Port = 3307
Socket =/opt/mariadb-data/mariadb. sock
User = mariadb

Copy the init. d script from the support-files file to the corresponding location:

[Root @ centOS7 opt] # cp mariadb/support-files/mysql. server/etc/init. d/mariadb
[Root @ centOS7 opt] # chmod + x/etc/init. d/mariadb

Edit/etc/init. d/mariadb and use mariadb to replace the mysql settings as follows:

-# Provides: mysql
+ # Provides: mariadb
-Basedir =
+ Basedir =/opt/mariadb
-Datadir =
+ Datadir =/opt/mariadb-data
-Lock_file_path = "$ lockdir/mysql"
+ Lock_file_path = "$ lockdir/mariadb"

You need to tell mariadb to read the unique cnf file. add -- defaults-file =/opt/mariadb-data/my after $ bindir/mysqld_safe. cnf. the final parameter settings should be as follows:

# Give extra arguments to mysqld with the my. cnf file. This script
# May be overwritten at next upgrade.
$ Bindir/mysqld_safe -- defaults-file =/opt/mariadb-data/my. cnf -- datadir = "$ datadir" -- pid-file = "$ mysqld_pid_file_path" $ other_args>/dev/null 2> & 1 &

Explicitly specify my. cnf as the input parameter to run mysql_install_db:

[Root @ centOS7 opt] # cd mariadb
[Root @ centOS7 mariadb] # scripts/mysql_install_db -- defaults-file =/opt/mariadb-data/my. cnf

Now you can start MariaDB like this:

[Root @ centOS7 opt] #/etc/init. d/mariadb start
Starting MySQL SUCCESS

Set MariaDB startup to system-level startup:

[Root @ centOS7 opt] # cd/etc/init. d
[Root @ centOS7 init. d] # chkconfig -- add mariadb
[Root @ centOS7 init. d] # chkconfig -- levels 3 mariadb on

Finally, the test now has two database service instances running:

[Root @ centOS7 ~] # Mysql-e "select version ();"
+ ----------- +
| VERSION () |
+ ----------- +
| 5.6.19 |
+ ----------- +
[Root @ mariadb-near-mysql ~] # Mysql-e "select version ();" -- socket =/opt/mariadb-data/mariadb. sock
+ -------------------- +
| VERSION () |
+ -------------------- +
| 10.0.12-MariaDB-log |
+ -------------------- +

Install LAMP (Apache with MariaDB and PHP) in CentOS/RHEL/Scientific Linux 6)

Implementation of MariaDB Proxy read/write splitting

How to compile and install the MariaDB database in Linux

Install MariaDB database using yum in CentOS

Install MariaDB and MySQL

MariaDB details: click here
MariaDB's: click here

This article permanently updates the link address:

Related Article

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.