Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Installation and configuration Guide for MySQL Multi-instance

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Operating system: CentOS 6.8

Virtual machine: VMware

Database: MySQL 5.1.62

Practical task: install and configure a multi-instance MySQL database

1. Install the dependency packages required by MySQL

[root@www~] # yum install ncurses-devel libaio-devel-y

two。 Start installing MySQL

1) set up MySQL user account

[root@www~] # useradd-s / sbin/nologin-M mysql

2) obtain MySQL software package

[root@www tools] #

Wget http://soft.vpser.net/datebase/mysql/mysql-5.1.62.tar.gz

3) compile and install

[root@wwwtools] # tar zxf mysql-5.1.62.tar.gz

[root@wwwmysql-5.1.62] #. / configure\

-- prefix=/usr/local/mysql\

-- with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock\

-- localstatedir=/usr/local/mysql/data\

-- enable-assembler\

-- enable-thread-safe-client\

-- with-mysqld-user=mysql\

-- with-big-tables\

-- without-debug\

-- with-pthread\

-- enable-assembler\

-- with-extra-charsets=complex\

-- with-readline\

-- with-ssl\

-- with-embedded-server\

-- enable-local-infile\

-- with-plugins=partition,innobase\

-- with-mysqld-ldflags=-all-static\

-- with-client-ldflags=-all-static

[root@wwwmysql-5.1.62] # make & & make install

3. Create a data file directory for multiple instances of MySQL

[root@www/] # mkdir-p / data/ {3306 3307} / data

[root@www/] # tree / data

4. Create a multi-instance profile

[root@wwwmysql-5.1.62] # / bin/cp support-files/my-small.cnf / etc/my.cnf

[root@www~] # vi / data/3306/my.cnf # script can be downloaded in the attachment

[root@www~] # vi / data/3307/my.cnf

5. Create MySQL multi-instance startup file

[root@www~] # vi / data/3306/mysql # script can be downloaded in the attachment

[root@www~] # vi / data/3307/mysql

6. Configure file permissions for multiple instances of MySQL

[root@www~] # chown-R mysql.mysql / data

7. How to configure the global path of MySQL

[root@wwwmysql-5.1.62] # echo 'export PATH=$PATH:/usr/local/mysql/bin' > > / etc/profile

[root@wwwmysql-5.1.62] # source / etc/profile

8. Initialize multi-instance database files

Root@www/] # mysql_install_db-- datadir=/data/3306/data-- user=mysql

Root@www/] # mysql_install_db-- datadir=/data/3307/data-- user=mysql

9. Start the MySQL multi-instance database

[root@www~] # / data/3306/msyql start

[root@www~] # / data/3307/msyql start

[root@www~] # netstat-lntup | grep 330

Tcp 0 0 0.0.0.0 3306 0.0.0.015 * LISTEN 4753/mysqld

Tcp 0 0 0.0.0.0 3307 0.0.0.015 * LISTEN 4753/mysqld

10. Configure multi-instance database to boot automatically

[root@www ~] # echo "/ data/3306/mysqlstart" > > / etc/rc.local

[root@www ~] # echo "/ data/3307/mysqlstart" > > / etc/rc.local

11. Log in to MySQL test

[root@www~] # mysql-S / data/3306/mysql.sock

[root@www~] # mysql-S / data/3307/mysql.sock

twelve。 Command to restart the corresponding database

[root@www~] # / data/3306/mysql stop

[root@www~] # / data/3307/mysql start

13.MySQL security configuration

[root@www~] # mysqladmin-u root-S / data/3306/mysql.sock password'* # set password

[root@www ~] # mysqladmin-u root-S/data/3307/mysql.sock password'*'# set password

[root@www~] # mysql-uroot-p-S/data/3306/mysql.sock # Login with password

[root@www~] # mysql-uroot-p-S / data/3307/mysql.sock

14. Note:

[root@wwwmysql] # killall mysqld # Kill the mysql process

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report