Legacy MySQL database, installing multi-instance Tutorials

Source: Internet
Author: User

#mysql the installation script is installed.

mkdir-v/usr/ Share /mysql/mysql-files

MKDIR-VP/DATA/MYSQL_DATA{1..4}

* Modify The user and owning group of the MySQL binary package directory

Chown Root.mysql-r/usr/share/mysql

* Modify MySQL Multi-instance data directory with data import / Export Exclusive directory of the owning user and owning group

Chown Mysql.mysql-r/usr/share/mysql/mysql-files/data/mysql_data{1..4}

* Configure MySQL configuration file

cat>> /etc/m Ulti . CNF <<eof

[Mysqld_multi]

Mysqld =/usr/sbin/mysqld

Mysqladmin =/usr/bin/mysqladmin

Log =/tmp/mysql_multi.log

[mysqld1]

DataDir =/data/mysql_data1

Socket =/tmp/mysql.sock1

Port = 7

user = MySQL

Performance_schema = Off

Innodb_buffer_pool_size = 32M

Bind_address = 0.0.0.0

Skip-name-resolve = 0

[mysqld2]

DataDir =/data/mysql_data2

Socket =/tmp/mysql.sock2

Port = 8

user = MySQL

Performance_schema = Off

Innodb_buffer_pool_size = 32M

Bind_address = 0.0.0.0

Skip-name-resolve = 0

[mysqld3]

DataDir =/data/mysql_data3

Socket =/tmp/mysql.sock3

Port = 9

user = MySQL

Performance_schema = Off

Innodb_buffer_pool_size = 32M

Bind_address = 0.0.0.0

Skip-name-resolve = 0

Eof

* Initialization of each instance [ after initialization is complete, the random password is included in the output log ] /var/log/mysqld.log

/usr/sbin/mysqld--initialize--user=mysql--datadir=/data/mysql_data1

/usr/sbin/mysqld--initialize--user=mysql--datadir=/data/mysql_data 2

/usr/sbin/mysqld--initialize--user=mysql--datadir=/data/mysql_data 3

* Instance Open

Mysqld_multi--defaults-extra-file=/etc/m Ulti . CNF start

Test

mysql-uroot-s/tmp/mysql.sock 1 -p password will be given to root when initializing Random Password

grep ' temporary password '/var/log/mysqld.log| Awk-f: ' {print $4} ' |awk ' Nr==2{print} '

Scok2 will nr==3

rep ' temporary password '/var/log/mysqld.log| awk-f: ' {print $4} ' |awk ' nr== 3 {print} '

In turn

ALTER USER ' root ' @ ' localhost ' identified by ' abc123 '; Change the password first

The contents of another instance can be compared by adding or deleting points.

Create Database test3306;

show databases;

by default,MySQL only lets you log on locally, and if you want to turn on remote connections, you need to modify the /etc/mysql/my.conf file.

I. Modification of /etc/mysql/my.conf
Find bind-address = 127.0.0.1 this line
change to bind-address = 0.0.0.0

granting permissions to users who need to log on remotely
support for root user allows remote connection to MySQL database
Grant all privileges on * * to ' root ' @ '% ' identified by 'abc123' with GRANT option;
Flush privileges;  

Use MySQL;

Select User, host from user;


This article from the "Linux Fairy Road" blog, reproduced please contact the author!

Legacy MySQL database, installing multi-instance Tutorials

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.