您的位置:首页 > 数据库 > MySQL

多实例mysql数据库安装详解

2016-07-01 18:33 731 查看
一、实验环境

系统:cetos6.5

软件:mysql-5.5.32.tar.gz

二、实验步骤

1.1 安装cmake软件

tar xf cmake-2.8.8.tar.gz

cd cmake-2.8.8

./configure

gmake

gmake install

1.2 创建用户和组及其安装mysql依赖包
groupadd mysql

useradd mysql -s /sbin/nologin -M msyql
yum -y install ncurses-devel

1.3 解压编译安装mysql

tar xf mysql-5.5.32.tar.gz

cd mysql-5.5.32.tar.gz

cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \
-DMYSQL_DATADIR=/application/mysql-5.5.32/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0

make && make install

1.4 配置环境变量写入/etc/profile文件中

PATH="/application/mysql/bin:$PATH"

1.5 创建多实例目录启动脚本配置文件及其授权

/data/
├── 3306
│ ├── data
│ ├── my.cnf
│ └── mysql
└── 3307
├── data
├── my.cnf
└── mysql
chown -R mysql.mysql /data/

find /data/ -type f -name "mysql"|xargs chmod +x

/data/3306/mysql start ---启动mysql进程

/data/3307/mysql start ---启动mysql进程

1.6 通过socket多实例方式登录mysql
mysql -S /data/3306/mysql.sock

mysql -S /data/3307/mysql.sock

1.7 修改密码

mysqladmin -uroot -S /data/3306/mysql.sock password '123'
mysqladmin -uroot -S /data/3307/mysql.sock password '123'

1.8 改密码后的登录方式
mysql -uroot -p -S /data/3306/mysql.sock

mysql -uroot -p -S /data/3307/mysql.sock

1.9 实现登录成功

~]#mysql -uroot -p -S /data/3306/mysql.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.32 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

~]#mysql -uroot -p -S /data/3307/mysql.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.32 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
本文出自 “叫醒你的不是闹钟而是梦想” 博客,请务必保留此出处http://purify.blog.51cto.com/10572011/1795031
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: