Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ MySQL multi-instance configuration     - Android official recommendation: DialogFragment create dialog (Programming)

- Fedora 22 users to install the VLC media player (Linux)

- Samba public folder permissions (Server)

- Binary search is really easy as you think you do (Programming)

- Oracle 11g partition maintenance (Nice) - Truncating And Partitions (Database)

- Java 8 perspective annotation types (Programming)

- MBR partitions under Linux (Linux)

- sed command (Linux)

- Android Fragment really fully resolve (Programming)

- The difference between Objective-C language nil, Nil, NULL, NSNull (Programming)

- Ubuntu download install and configure Plank Dock (Linux)

- CentOS 7 update source - the use of domestic sources 163 yum (Linux)

- The Hill sorting algorithm (Programming)

- Android Fragment everything you need to know (Programming)

- Regular expressions in Perl (Programming)

- Git delete files (Linux)

- Intrusion analysis and prevention tools Knark under Linux platform (Linux)

- DRBD daily management (Server)

- Use small network command to check whether PC Security (Linux)

- ethtool implementation framework and application in Linux (Linux)

 
         
  MySQL multi-instance configuration
     
  Add Date : 2017-08-31      
         
         
         
  Experimental environment: RHEL6.4 to minimize installation, mysql installation package is a universal binary installation package, version mysql-5.6.26

1. Create a mysql user

#useradd -M -s / sbin / nologin mysql

#yum -y install ncurses-devel libaio-devel

# Install mysql dependencies, otherwise unable to initialize the following success

2. Unzip the package

# Tar xf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz -C / usr / local

# Mv /usr/local/mysql-5.6.26-linux-glibc2.5-x86_64/ / usr / local / mysql

3. Create a directory

# Mkdir / data / {3306,3307} / data -pv

# Mkdir / data / {3306,3307} / log -pv

# Tree / data / # View tree

4. / data / 3306 in New my.cnf

# Cd / data / 3306 /

# Vim my.cnf

[Client]

port = 3306

socket = /data/3306/mysql.sock

[Mysqld]

port = 3306

socket = /data/3306/mysql.sock

pid-file = /data/3306/data/mysql.pid

basedir = / usr / local / mysql

datadir = / data / 3306 / data

server-id = 1

# Log-bin = mysql-bin

# Log-bin-index = mysql-bin.index

# LOGGING

log_error = / data / 3306 / log / mysql-error.log

slow_query_log_file = / data / 3306 / log / mysql-slow.log

slow_query_log = 1

5. / data / 3307 in New my.cnf

# Cd ../3307/

# Vim my.cnf

[Client]

port = 3307

socket = /data/3307/mysql.sock

[Mysqld]

port = 3307

socket = /data/3307/mysql.sock

pid-file = /data/3307/data/mysql.pid

basedir = / usr / local / mysql

datadir = / data / 3307 / data

server-id = 2

# Log-bin = mysql-bin

# Log-bin-index = mysql-bin.index

# LOGGING

log_error = / data / 3307 / log / mysql-error.log

slow_query_log_file = / data / 3307 / log / mysql-slow.log

slow_query_log = 1

 6. Create mysql startup files in / data / 3306 in

# Cd / data / 3306 /

# Vim mysql

#! / Bin / sh

[-f /etc/init.d/functions] &&. /etc/init.d/functions

port = 3306

mysql_user = "root"

mysql_pwd = ""

mysql_sock = "/ data / $ {port} /mysql.sock"

CmdPath = "/ usr / local / mysql / bin"

#startup function

usage () {

printf "Usage: / data / $ {port} / mysql {start | stop | restart} \ n"

}

function_start_mysql ()

{

if [! -e "$ mysql_sock"]; then

/ Bin / sh $ {CmdPath} / mysqld_safe --defaults-file = / data / $ {port} /my.cnf 2> & 1> / dev / null &

action "Starting MySQL ..." / bin / true

else

printf "MySQL is running ... \ n"

exit

fi

}

#stop function

function_stop_mysql ()

{

if [! -e "$ mysql_sock"]; then

printf "MySQL is stopped ... \ n"

exit

else

action "Stoping MySQL ..." / bin / true

$ {CmdPath} / mysqladmin -u $ {mysql_user} -p $ {mysql_pwd} -S /data/${port}/mysql.sock shutdown

fi

}

#restart function

function_restart_mysql ()

{

function_stop_mysql &> / dev / null

sleep 2

function_start_mysql &> / dev / null

action "Restarting MySQL ..." / bin / true

}

if [$ # -ne 1]; then

usage

fi

case $ 1 in

start)

function_start_mysql

;;

stop)

function_stop_mysql

;;

restart)

function_restart_mysql

;;

*)

usage

esac

#chmod + x mysql

7, the new mysql startup file in / data / 3307 in

# Cd / data / 3307 /

 # Vim mysql

#! / Bin / bash

[-f /etc/init.d/functions] &&. /etc/init.d/functions

port = 3307

mysql_user = "root"

mysql_pwd = ""

mysql_sock = "/ data / $ {port} /mysql.sock"

CmdPath = "/ usr / local / mysql / bin"

usage () {

printf "Usage: / data / $ {port} / mysql {start | stop | restart} \ n"

}

#startup function

function_start_mysql ()

{

if [! -e "$ mysql_sock"]; then

/ Bin / sh $ {CmdPath} / mysqld_safe --defaults-file = / data / $ {port} /my.cnf 2> & 1> / dev / null &

action "Starting MySQL ..." / bin / true

else

printf "MySQL is running ... \ n"

exit

fi

}

#stop function

function_stop_mysql ()

{

if [! -e "$ mysql_sock"]; then

printf "MySQL is stopped ... \ n"

exit

else

action "Stoping MySQL ..." / bin / true

$ {CmdPath} / mysqladmin -u $ {mysql_user} -p $ {mysql_pwd} -S /data/${port}/mysql.sock shutdown

fi

}

#restart function

function_restart_mysql ()

{

function_stop_mysql &> / dev / null

sleep 2

function_start_mysql &> / dev / null

action "Restarting MySQL ..." / bin / true

}

case $ 1 in

start)

function_start_mysql

;;

stop)

function_stop_mysql

;;

restart)

function_restart_mysql

;;

*)

usage

esac

#chmod + x mysql

8. Change the file owner and permissions

#chown -R mysql: mysql / data

9. Add the mysql Startup Path

 #echo 'export PATH = $ PATH: / usr / local / mysql / bin' >> / etc / profile
  #source / etc / profile

10. Initialize Database

 # Cd / usr / local / mysql / scripts /

 #. / Mysql_install_db --defaults-file = / data / 3306 / my.cnf --user = mysql --basedir = / usr / local / mysql --datadir = / data / 3306 / data

 #. / Mysql_install_db --defaults-file = / data / 3307 / my.cnf --user = mysql --basedir = / usr / local / mysql --datadir = / data / 3307 / data

11. Start mysql

 # / Data / 3306 / mysql start
# / Data / 3307 / mysql start
#netstat -lntp | grep 330 # to check whether the boot process

12. landing mysql

1) # mysql -S /data/3306/mysql.sock # just installed the mysql password is not logged in

# If unsuccessful, mysql-error.log Check the log / data / 3306 / log directory, exclude each error

If successful landing, the following change password

mysql> update mysql.user set password = password ( "123456") where user = 'root';
mysql> flush privileges;

It is not recommended to change the password in the shell environment, otherwise I just look the command history will be able to see the password. Of course, you can also be carried out under the shell, but remember to clear the command history records.

2) Similarly, using the above method to modify the 3307 login password
# Mysql -S /data/3307/mysql.sock

 mysql> update mysql.user set password = password ( "123456") where user = 'root';
mysql> flush privileges;

3) should change the password above written back mysql startup files (Otherwise each time you start, shut down, restart mysql must enter a password)

# Sed -i 's / mysql_pwd = \ "\" / mysql_pwd = \ "123456 \" / g' / data / 3306 / mysql
#sed -i 's / mysql_pwd = \ "\" / mysql_pwd = \ "123456 \" / g' / data / 3307 / mysql

You can also manually modify

#vim / data / 3306 / mysql


# Vim / data / 3307 / mysql


13. Restart mysql

# / Data / 3306 / mysql restart


# / Data / 3307 / mysql restart

#netstat -lntp | grep 330

14. knowledge

When entering mysql, remember to add -S to specify the path to mysql socket

# Mysql -u root -p -S /data/3307/mysql.sock

The following command can be smoothly closed mysql

# Mysqladmin -uroot -p123456 -S /data/3306/mysql.sock shutdown
     
         
         
         
  More:      
 
- Java synchronization mechanism: synchronized, wait, notify (Programming)
- LVS + Keepalived the DR mode (Server)
- 2 minutes to read large data framework Hadoop and Spark similarities and differences (Server)
- Teach you how to protect the Linux operating system security tips (Linux)
- Nodejs mysql pool Example (Programming)
- Transplant spider to MySQL 5.6 (Database)
- Advanced Search Oracle study notes (Database)
- Nginx-1.9.7 TCP reverse proxy (Server)
- Android Studio simple setup (Linux)
- Kubernetes (k8s) environment to build combat (Server)
- Nginx DHCP TFTP Kickstart set up automatic installation system (Server)
- RedHat virtual machine to install VMware Tools (Linux)
- The first deployment of cross-platform operation Rafy record (Server)
- CentOS ClamAV antivirus package updates (Linux)
- Bash How to read a file line by line (Programming)
- Hanoi problem Java Solution (Programming)
- Oracle local user login authentication fails ORA-01031 insufficient privileges (Database)
- CoreCLR compiled in Linux CentOS (Linux)
- Log analysis is done with Grafana Elasticsearch (Server)
- Oracle11g CRS-0184 Problem Solving (Database)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.