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

How to install single instance and multiple instances of mysql5.6 in centos6.5 system

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

Share

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

The following brings you about the centos6.5 system how to install mysql5.6 single instance and multi-instance, if you are interested, take a look at this article, I believe that after reading the centos6.5 system how to install mysql5.6 single instance and multi-instance will be of some help to you.

Install mysql

Create a mysql user

Useradd mysql / / existing does not need to be created

Uninstall the original mysql rpm package

Rpm-qa | grep mysql / / query whether there are related packages

Yum-y remove * mysql* / / I uninstalled it with yum here.

Turn off the firewall, turn off selinux

Service iptables stop / / personal habit to turn off the firewall

Sed-I's etc/selinux/config SelinuxplenforcingAccording to SELINUXAfter

Setenforce 0

Install the required dependency packages

Yum-y install make gcc gcc-c++ gcc-gfortran flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap lsof

Install cmake

Cmake is required to configure compilation after the Mysql5.6 version

Tar-zxvf cmake-2.8.5.tar.gz

Cd cmake-2.8.5

. / configure

Gmake & & gmake install

Start installing mysql

Tar-zxvf mysql-5.6.4-m7.tar.gz

Cd mysql-5.6.4-m7

Cmake\

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\

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

-DSYSCONFDIR=/etc\

-DMYSQL_USER=mysql\

-DWITH_MYISAM_STORAGE_ENGINE=1\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_MEMORY_STORAGE_ENGINE=1\

-DWITH_READLINE=1\

-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock\

-DMYSQL_TCP_PORT=3306\

-DENABLED_LOCAL_INFILE=1\

-DWITH_PARTITION_STORAGE_ENGINE=1\

-DEXTRA_CHARSETS=all\

-DDEFAULT_CHARSET=utf8\

-DDEFAULT_COLLATION=utf8_general_ci\

-DWITH_DEBUG=0\

-DWITH_SSL=system

Make & & make install

=

Installation of a single instance

After installation, related operations

Modify mysql installation directory permissions

Chmod + w / usr/local/msyql

Chown-R mysql.mysql / usr/local/mysql

/ / when starting the MySQL service, the my.cnf will be searched in a certain order, first in the / etc directory. If you can't find it, it will search for "$basedir/my.cnf", which is / usr/local/mysql/my.cnf under the installation directory, which is the default location of the configuration file for the new version of MySQL! Note: after the minimum installation of the CentOS 6.x operating system is complete, there will be a my.cnf in the / etc directory, and this file needs to be renamed to something else. Such as: / etc/my.cnf.bak, otherwise, the file will interfere with the correct configuration of the MySQL installed by the source code, resulting in failure to start. Since we have uninstalled the mysq library after the minimum installation, there is no need to do so.

Cd support-files/

If there is still my.cnf, please back it up.

Mv / etc/my.cnf / etc/my.cnf.bak

Copy the configuration file to etc

Cp my-medium.cnf / etc/my.cnf

/ / execute the initialization configuration script, create the database and table that comes with the system, and pay attention to the path of the configuration file.

/ usr/local/mysql/scripts/mysql_install_db-defaults-file=/etc/my.cnf-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data-user=mysql

/ / copy the support-files service script under the mysql installation directory to the init.d directory

# copy script

Cp support-files/mysql.server / etc/init.d/mysqld

# Grant permissions

Chmod + x / etc/init.d/mysqld

# set Boot Startup

Chkconfig mysqld on

# start MySQL

Service mysqld start or / etc/init.d/mysql start

After MySQL5.6.x starts successfully, root does not have a password by default. We need to set the root password. Before setting up, we need to set PATH, otherwise, we can't call mysql directly.

Modify / etc/profile file

Vim / etc/profile

Add at the end of the file

PATH=/usr/local/mysql/bin:$PATH

# Let the configuration take effect immediately

Source / etc/profile

# Log in test. There is no password by default. Enter directly and then enter.

Mysql-uroot-p

Set the mysqlroot user password

Mysqladmin-u root password "newpass"

# if root has already set a password, use the following methods

Mysqladmin-uroot-ppassword password "newpass"

# verify the mysql installation path

Ls-ld / usr/local/mysql/

=

Installation of multiple instances

Then the above source package installation is complete and starts.

1. Create a multi-instance database folder

Mkdir-pv / usr/local/mysql/data/ {3306 ~ 3307 ~ 3308}

Chown-R mysql.mysql / usr/local/mysql/data/

2. Initialize the database

Cd / usr/local/mysql

Scripts/mysql_install_db-user=mysql-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data/3306/

Scripts/mysql_install_db-user=mysql-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data/3307/

Scripts/mysql_install_db-user=mysql-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data/3308/

3. Prepare profile # provide multiple profile templates

Cd bin

. / mysqld_multi-example > / usr/local/mysql/data/multi.cnf

4. Modify the template file (comment out the unused ones)

Vim / usr/local/mysql/data/multi.cnf

[mysqld_multi] cd

Mysqld = / usr/local/mysql/bin/mysqld_safe

Mysqladmin = / usr/local/mysql/bin/mysqladmin

User = root

# password = root # must be enabled after the password is set, otherwise there will be a problem with the command to stop (the password of the three instance databases is the same)

[mysqld1]

Socket = / tmp/mysql.sock1

Port = 3306

Pid-file = / usr/local/mysql/data/3306/mysql.pid

Datadir = / usr/local/mysql/data/3306/

[mysqld2]

Socket = / tmp/mysql.sock2

Port = 3307

Pid-file = / usr/local/mysql/data/3307/mysql.pid

Datadir = / usr/local/mysql/data/3307/

# language = / usr/local/mysql/share/mysql/english

# user = unix_user1

[mysqld3]

# mysqld = / path/to/mysqld_safe

# ledir = / path/to/mysqld-binary/

# mysqladmin = / path/to/mysqladmin

Socket = / tmp/mysql.sock3

Port = 3308

Pid-file = / usr/local/mysql/data/3308/mysql.pid

Datadir = / usr/local/mysql/data/3308/

# language = / usr/local/mysql/share/mysql/swedish

# user = unix_user2

5. Modify / etc/profile file

Vim / etc/profile

Add at the end of the file

PATH=/usr/local/mysql/bin:$PATH

# Let the configuration take effect immediately

Source / etc/profile

6. Start the msyql database

Mysqld_multi-defaults-file=/usr/local/mysql/data/multi.cnf start 1, 2, 3

View port statu

Netstat-anpt | grep mysqld

Tcp 0 0 0.0.0.0 3307 0.0.0.015 * LISTEN 25470/mysqld

Tcp 0 0 0.0.0.0 3308 0.0.0.015 * LISTEN 25476/mysqld

Tcp 0 0 0.0.0.0 3306 0.0.0.015 * LISTEN 25453/mysqld

7, set the mysql password

Mysqladmin-uroot-S / tmp/mysql.sock1 password "root"

Mysqladmin-uroot-S / tmp/mysql.sock2 password "root"

Mysqladmin-uroot-S / tmp/mysql.sock3 password "root"

8, enter the database

Mysql-S / tmp/mysql.sock1-proot

9. There are three ways to close the database.

Mysqladmin-S / tmp/mysql.sock1 shutdown-proot

Mysqld_multi-defaults-file=/usr/local/mysql/data/multi.cnf stop 1, 2, 3

Read the details above about how to install single instance and multi-instance of mysql5.6 in centos6.5 system, and whether you have gained anything. If you want to know more about it, you can continue to follow our industry information section.

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