在mysql中运行多个mysql实例

发布于 2024-07-26 07:11:05 字数 2192 浏览 5 评论 0原文

我想在同一台机器上的两个不同端口上使用 MySQL 服务器。 我制作了两个单独的配置文件。 当我尝试连接到我定义的第二个端口上的 MySQL 服务器时,我无法连接。 运行MySQL的操作系统是Windows Vista。 我还尝试在指定端口后从命令行启动 mysqld 。

这是我为 MySQL 服务器更改的示例文件,以便从两个不同的端口读取:

# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]

port=3306

[mysql]
mysql-path="C:\Program Files\MySQL\MySQL Server 5.1\bin"
default-character-set=latin1

[client]

port=3307

[mysql1]
mysql1-path="C:\Program Files\MySQL2\MySQL Server 5.1\bin"
default-character-set=latin1

# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
#
[mysqld]
mysqld-path="C:\Program Files\MySQL\MySQL Server 5.1\bin\"

# The TCP/IP Port the MySQL Server will listen on
port=3306

#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 5.1/"

#Path to the database root
datadir="C:/ProgramData/MySQL/MySQL Server 5.1/Data/"
#
server_id=1

[mysqld1]
# The TCP/IP Port the MySQL Server will listen on
port=3307
server_id=2
mysqld1-path="C:\Program Files\MySQL2\MySQL Server 5.1\bin\"

#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL2/MySQL Server 5.1/"

#Path to the database root
datadir="C:/ProgramData/MySQL2/MySQL Server 5.1/Data/"
#
# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=latin1

# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB

# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

I want to use MySQL server on two different ports on the same machine. I have made two separate config files. When I'm trying to connect to the MySQL server on the second port I defined then I can't connect. The OS running MySQL is Windows Vista. I also tried to start mysqld from command line after specifying port.

This is the sample file I have changed for MySQL server to read from two different ports:

# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]

port=3306

[mysql]
mysql-path="C:\Program Files\MySQL\MySQL Server 5.1\bin"
default-character-set=latin1

[client]

port=3307

[mysql1]
mysql1-path="C:\Program Files\MySQL2\MySQL Server 5.1\bin"
default-character-set=latin1

# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
#
[mysqld]
mysqld-path="C:\Program Files\MySQL\MySQL Server 5.1\bin\"

# The TCP/IP Port the MySQL Server will listen on
port=3306

#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 5.1/"

#Path to the database root
datadir="C:/ProgramData/MySQL/MySQL Server 5.1/Data/"
#
server_id=1

[mysqld1]
# The TCP/IP Port the MySQL Server will listen on
port=3307
server_id=2
mysqld1-path="C:\Program Files\MySQL2\MySQL Server 5.1\bin\"

#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL2/MySQL Server 5.1/"

#Path to the database root
datadir="C:/ProgramData/MySQL2/MySQL Server 5.1/Data/"
#
# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=latin1

# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB

# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ゝ杯具 2024-08-02 07:11:05

最好使用 mysql_multi http://www.pythian.com/ blog/using-mysqld_multi-to-manage-multiple-servers/

配置副本是肮脏的黑客恕我直言

better to use mysql_multi http://www.pythian.com/blog/using-mysqld_multi-to-manage-multiple-servers/

copies of configs are dirty hack imho

纸短情长 2024-08-02 07:11:05

根据您的服务器/操作系统的不同,安装过程略有不同。

对于 Linux,你可能会发现这很有用 - http://code.openark.org/blog/mysql/manually-installing-multiple-mysql-instances-on-linux-howto

Google一下,你可能也会找到其他的。

The installation procedure differs slightly based on your server/operating system.

For linux you might find this useful - http://code.openark.org/blog/mysql/manually-installing-multiple-mysql-instances-on-linux-howto

Google it and you might find for others too.

迎风吟唱 2024-08-02 07:11:05

您还需要在命令行上指定不同的datadir(即包含数据库文件的目录)。 您不能在不同的实例中打开相同的数据库,因为它们会相互锁定和/或导致数据损坏。

You need to also specify a different datadir (i.e. the directory which contains the database files) on the command-line. You cannot open the same databases in different instances, as they would lock each other and/or cause data-corruption.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文