多实例mysql数据库安装详解

  1. 云栖社区>
  2. 博客>
  3. 正文

多实例mysql数据库安装详解

科技小先锋 2017-11-29 21:37:00 浏览815
展开阅读全文

一、实验环境 

系统: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>



本文转自chengong1013 51CTO博客,原文链接:http://blog.51cto.com/purify/1795031,如需转载请自行联系原作者

网友评论

登录后评论
0/500
评论