安装多个mysql实例(debian版本)

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
我的博客已迁移到xdoujiang.com请去那边和我交流
前言:领导要求在1台DELL R710上安装多个mysql实例
一、安装第1个实例
1、当前系统
cat  /etc/debian_version 
6.0.10
2、查看安装包
apt-cache search mysql-server| grep  "mysql-server"
mysql-server-5.1 - MySQL database server binaries and system database setup
mysql-server-core-5.1 - MySQL database server binaries
mysql-server - MySQL database server (metapackage depending on the latest version)
3、安装mysql(会安装mysql相关的一系列的包)
apt-get -y  install  mysql-server --force- yes
二、安装第二个实例
1、创建目录(我这边将第二个实例安装在 /opt 下)
cd  /opt/
mkdir  mysql3307
2、复制mysql表和配置文件
cd  /var/lib/mysql/
cp  -a mysql  /opt/mysql3307/
cp  /etc/mysql/my .cnf  /opt/mysql3307/
3、修改配置(一般就是改下port和sock和pid和datadir路径)
port            = 3307
socket          =  /var/run/mysqld/mysqld3307 .sock
pid- file         /var/run/mysqld/mysqld3307 .pid
datadir         =  /opt/mysql3307
4、给mysql权限
chown  -R mysql.root  /opt/mysql3307/
5、启mysql(这里使用mysql用户启)
修改 /etc/passed 文件
mysql:x:102:104:MySQL Server,,,: /var/lib/mysql : /bin/bash
su  - mysql
/usr/sbin/mysqld  --defaults- file = /opt/mysql3307/my .cnf --basedir= /usr  --datadir= /opt/mysql3307/  --user=mysql --pid- file = /var/run/mysqld/mysqld3307 .pid --skip-external-locking --port=3307 --socket= /var/run/mysqld/mysqld3307 .sock &
[1] 2484
150505  9:30:06 [Note] Plugin  'FEDERATED'  is disabled.
150505  9:30:07  InnoDB: Initializing buffer pool, size = 8.0M
150505  9:30:07  InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data  file  . /ibdata1  did not exist:
InnoDB: a new database to be created!
150505  9:30:07  InnoDB: Setting  file  . /ibdata1  size to 10 MB
InnoDB: Database physically writes the  file  full: wait...
150505  9:30:07  InnoDB: Log  file  . /ib_logfile0  did not exist: new to be created
InnoDB: Setting log  file  . /ib_logfile0  size to 5 MB
InnoDB: Database physically writes the  file  full: wait...
150505  9:30:07  InnoDB: Log  file  . /ib_logfile1  did not exist: new to be created
InnoDB: Setting log  file  . /ib_logfile1  size to 5 MB
InnoDB: Database physically writes the  file  full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
150505  9:30:07  InnoDB: Started; log sequence number 0 0
150505  9:30:07 [Note] Event Scheduler: Loaded 0 events
150505  9:30:07 [Note]  /usr/sbin/mysqld : ready  for  connections.
Version:  '5.1.73-1'   socket:  '/var/run/mysqld/mysqld3307.sock'   port: 3307  (Debian)
6、最后查看2个mysql实例是否正常运行着
ps  aux| grep  mysql
root      2152  0.0  0.0   3956   616 ?        S    08:53   0:00  /bin/sh  /usr/bin/mysqld_safe
mysql     2276  0.0  3.6 182456 37560 ?        Sl   08:53   0:01  /usr/sbin/mysqld  --basedir= /usr  --datadir= /var/lib/mysql  --user=mysql --pid- file = /var/run/mysqld/mysqld .pid --socket= /var/run/mysqld/mysqld .sock --port=3306
root      2277  0.0  0.0   5348   688 ?        S    08:53   0:00 logger -t mysqld -p daemon.error
mysql     2480  0.0  0.1  36884  1232 pts /0     S    09:29   0:00  su  - mysql
mysql     2481  0.0  0.1  19220  1976 pts /0     S    09:29   0:00 - su
mysql     2484  5.5  3.6 174064 37004 pts /0     Sl   09:30   0:00  /usr/sbin/mysqld  --defaults- file = /opt/mysql3307/my .cnf --basedir= /usr  --datadir= /opt/mysql3307/  --user=mysql --pid- file = /var/run/mysqld/mysqld3307 .pid --skip-external-locking --port=3307 --socket= /var/run/mysqld/mysqld3307 .sock
mysql     2495  0.0  0.1  16340  1136 pts /0     R+   09:30   0:00  ps  aux
mysql     2496  0.0  0.0   7548   820 pts /0     S+   09:30   0:00  grep  mysql
7、登陆2个mysql实例看下
mysql -uroot -predhat -S  /var/run/mysqld/mysqld .sock 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection  id  is 54
Server version: 5.1.73-1 (Debian)
 
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> quit
Bye
mysql -uroot -predhat -S  /var/run/mysqld/mysqld3307 .sock 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection  id  is 1
Server version: 5.1.73-1 (Debian)
 
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> quit
Bye
mysql@10:~$ 
三、引擎
当前版本引擎
mysql -uroot -predhat -S  /var/run/mysqld/mysqld .sock -e  "show engines;"
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine     | Support | Comment                                                        | Transactions | XA   | Savepoints |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB     | YES     | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| MRG_MYISAM | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| BLACKHOLE  | YES     |  /dev/null  storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| CSV        | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| MEMORY     | YES     | Hash based, stored  in  memory, useful  for  temporary tables      | NO           | NO   | NO         |
| FEDERATED  | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| ARCHIVE    | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| MyISAM     | DEFAULT | Default engine as of MySQL 3.23 with great performance         | NO           | NO   | NO         |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
配置修改默认引擎为innodb
是在[mysqld]这个里面
default_table_type = innodb
5.5的话默认引擎直接是innodb了 不需要修改









本文转自 xdoujiang 51CTO博客,原文链接:http://blog.51cto.com/7938217/1650434,如需转载请自行联系原作者
相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
Docker Compose V2 安装常用数据库MySQL+Mongo
以上内容涵盖了使用 Docker Compose 安装和管理 MySQL 和 MongoDB 的详细步骤,希望对您有所帮助。
187 42
vb6读取mysql,用odbc mysql 5.3版本驱动
通过以上步骤,您可以在VB6中使用ODBC MySQL 5.3驱动连接MySQL数据库并读取数据。配置ODBC数据源、编写VB6代码
73 32
CentOS7仅安装部署MySQL80客户端
通过上述步骤,你可以在CentOS 7上成功安装并配置MySQL 8.0客户端。这个过程确保你能够使用MySQL客户端工具连接和管理远程的MySQL数据库,而不需要在本地安装MySQL服务器。定期更新MySQL客户端可以确保你使用的是最新的功能和安全修复。
295 16
《docker高级篇(大厂进阶):1.Docker复杂安装详说》包括:安装mysql主从复制、安装redis集群
《docker高级篇(大厂进阶):1.Docker复杂安装详说》包括:安装mysql主从复制、安装redis集群
148 14
《docker基础篇:8.Docker常规安装简介》包括:docker常规安装总体步骤、安装tomcat、安装mysql、安装redis
《docker基础篇:8.Docker常规安装简介》包括:docker常规安装总体步骤、安装tomcat、安装mysql、安装redis
162 7
Windows Server 安装 MySQL 8.0 详细指南
安装 MySQL 需要谨慎,特别注意安全配置和权限管理。根据实际业务需求调整配置,确保数据库的性能和安全。
406 9
docker拉取MySQL后数据库连接失败解决方案
通过以上方法,可以解决Docker中拉取MySQL镜像后数据库连接失败的常见问题。关键步骤包括确保容器正确启动、配置正确的环境变量、合理设置网络和权限,以及检查主机防火墙设置等。通过逐步排查,可以快速定位并解决连接问题,确保MySQL服务的正常使用。
96 82
缓存与数据库的一致性方案,Redis与Mysql一致性方案,大厂P8的终极方案(图解+秒懂+史上最全)
缓存与数据库的一致性方案,Redis与Mysql一致性方案,大厂P8的终极方案(图解+秒懂+史上最全)
MySQL生产环境迁移至YashanDB数据库深度体验
这篇文章是作者将 MySQL 生产环境迁移至 YashanDB 数据库的深度体验。介绍了 YashanDB 迁移平台 YMP 的产品相关信息、安装步骤、迁移中遇到的各种兼容问题及解决方案,最后总结了迁移体验,包括工具部署和操作特点,也指出功能有优化空间及暂不支持的部分,期待其不断优化。