Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 两台MySQL服务器_Php_Mysql_Sockets_Port - Fatal编程技术网

Php 两台MySQL服务器

Php 两台MySQL服务器,php,mysql,sockets,port,Php,Mysql,Sockets,Port,我想通过mysqld\u multi使用2台SQL服务器。我可以在端口3306上成功运行一个,但现在我正在尝试在3307上创建一个全新的服务器。这是我在/etc/mysql/my.cnf中的配置: # # The MySQL database server configuration file. # # You can copy this to one of: # - "/etc/mysql/my.cnf" to set global options, # - "~/.my.cnf" to se

我想通过
mysqld\u multi
使用2台SQL服务器。我可以在端口3306上成功运行一个,但现在我正在尝试在3307上创建一个全新的服务器。这是我在/etc/mysql/my.cnf中的配置:

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.

[mysqld_multi]
mysqld     = /usr/bin/mysqld_safe
mysqladmin = /usr/bin/mysqladmin
user       = root
password   = <mypass>

[client]
port        = 3306
socket      = /var/run/mysqld/mysqld.sock

[client2]
port        = 3307
socket      = /var/run/mysqld/mysqld2.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0

[mysqld]
#
# * Basic Settings
#

#
# * IMPORTANT
#   If you make changes to these settings and your system uses apparmor, you may
#   also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.
#

user        = mysql
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address       = 127.0.0.1
#
# * Fine Tuning
#
key_buffer      = 16M
max_allowed_packet  = 16M
thread_stack        = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit   = 1M
query_cache_size        = 16M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1

log_error                = /var/log/mysql/error.log

# Here you can see queries with especially long duration
#log_slow_queries   = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id      = 1
#log_bin            = /var/log/mysql/mysql-bin.log
expire_logs_days    = 10
max_binlog_size         = 100M
#binlog_do_db       = include_database_name
#binlog_ignore_db   = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem



[mysqldump]
quick
quote-names
max_allowed_packet  = 16M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer      = 16M

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
#
#MySQL数据库服务器配置文件。
#
#您可以将其复制到以下位置之一:
#-“/etc/mysql/my.cnf”设置全局选项,
#-“~/.my.cnf”以设置用户特定的选项。
# 
#可以使用程序支持的所有长选项。
#使用--help运行程序以获取可用选项的列表,并使用
#--打印默认值,以查看它实际理解和使用的内容。
#
#有关解释,请参阅
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
#这将传递给所有mysql客户端
#据报道,密码应该用记号/引号括起来
#特别是如果它们包含“#”字符。。。
#更改套接字位置时,请记住编辑/etc/mysql/debian.cnf。
[mysqld_multi]
mysqld=/usr/bin/mysqld\u safe
mysqladmin=/usr/bin/mysqladmin
用户=根
密码=
[客户]
端口=3306
socket=/var/run/mysqld/mysqld.sock
[客户2]
端口=3307
socket=/var/run/mysqld/mysqld2.sock
#下面是一些特定程序的条目
#以下值假设您至少有32M ram
#正式名称为[safe_mysqld]。两个版本当前都已解析。
[mysqld_safe]
socket=/var/run/mysqld/mysqld.sock
尼斯=0
[mysqld]
#
#*基本设置
#
#
#*重要
#如果您对这些设置进行了更改,并且您的系统使用了apparmor,您可能会
#还需要调整/etc/apparmor.d/usr.sbin.mysqld。
#
user=mysql
socket=/var/run/mysqld/mysqld.sock
端口=3306
basedir=/usr
datadir=/var/lib/mysql
tmpdir=/tmp
跳过外部锁定
#
#现在,默认设置是只在网络上侦听,而不是跳过网络
#本地主机,它更兼容,而且安全性也不低。
#绑定地址=127.0.0.1
#
#*微调
#
按键缓冲=16M
允许的最大数据包数=16M
线程\u堆栈=192K
线程\缓存\大小=8
#这将替换启动脚本,并在需要时检查MyISAM表
#他们第一次被触碰
myisam恢复=备份
#最大连接数=100
#表_cache=64
#线程并发性=10
#
#*查询缓存配置
#
查询缓存限制=1M
查询\缓存\大小=16M
#
#*日志记录和复制
#
#两个位置都由cronjob旋转。
#请注意,此日志类型是性能杀手。
#从5.1开始,您可以在运行时启用日志!
#常规日志文件=/var/log/mysql/mysql.log
#一般日志=1
log\u error=/var/log/mysql/error.log
#在这里,您可以看到持续时间特别长的查询
#log\u slow\u查询=/var/log/mysql/mysql-slow.log
#长查询时间=2
#不使用索引的日志查询
#
#以下内容可用于轻松回放备份日志或进行复制。
#注意:如果您正在设置复制从机,请参阅README.Debian about
#您可能需要更改的其他设置。
#服务器id=1
#log_bin=/var/log/mysql/mysql-bin.log
过期天数=10天
最大尺寸=100M
#binlog\u do\u db=包含\u数据库\u名称
#binlog\u ignore\u db=包含\u数据库\u名称
#
#*InnoDB
#
#默认情况下,InnoDB是通过/var/lib/mysql/中的10MB数据文件启用的。
#阅读手册了解更多与InnoDB相关的选项。有很多!
#
#*安全功能
#
#如果您想要chroot,也请阅读手册!
#chroot=/var/lib/mysql/
#
#对于生成SSL证书,我建议使用OpenSSL GUI“tinyca”。
#
#sslca=/etc/mysql/cacert.pem
#ssl证书=/etc/mysql/server-cert.pem
#ssl key=/etc/mysql/server-key.pem
[mysqldump]
快的
引述姓名
允许的最大数据包数=16M
[mysql]
#无自动刷新功能#mysql启动速度更快,但无需完成制表符
[香港国际会计准则及守则]
按键缓冲=16M
#
#*重要提示:可以覆盖此文件中的设置的其他设置!
#文件必须以“.cnf”结尾,否则将被忽略。
#
!includedir/etc/mysql/conf.d/

但是,当我将phpMyAdmin中的端口更改为3307时,我仍然看到与3306中的数据库相同的数据库:(.我做错了什么?

您必须更改
[mysqld]
部分中的端口,这是服务器本身。
[client]
部分用于…客户端,如
mysql
命令行应用程序

不能从同一个文件配置两台服务器。您需要有两个单独的my.cnf,并通过命令行参数将服务器的每个实例指向这两个文件中的一个

此外,您还必须确保客户端应用程序(如mysql)使用正确的my.cnf文件来查找自己的端口。默认情况下,它们只查找my.cnf


有什么理由需要运行两个物理上不同的mysql实例吗?你知道,你可以在一个服务器实例中托管多个单独的数据库。

谢谢,是的:我想要一个用于开发的服务器和一个员工无法访问的真正的服务器。因此,如果出现问题,真正的服务器仍然可以工作。我如何让
mysql
同时使用这两个服务器呢nfig文件?类似于
mysql start-P 3307/etc/my2.cnf
我想?服务器的命令行参数记录在这里: