Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.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
远程访问xammp mysql数据库_Mysql_Xampp - Fatal编程技术网

远程访问xammp mysql数据库

远程访问xammp mysql数据库,mysql,xampp,Mysql,Xampp,我是PHP新手,我正在尝试从另一台pc远程连接xampp。但我遇到以下错误: 警告:mysqli_connect():(HY000/1130):主机“103.255.6.68”不可用 允许在中连接到此MariaDB服务器 第3行的C:\xampp\htdocs\example\index.php 我的连接字符串是 <?php //mysqli_connect(host,username,password,dbname,port,socket); $con=mysqli_connect('

我是PHP新手,我正在尝试从另一台pc远程连接xampp。但我遇到以下错误:

警告:mysqli_connect():(HY000/1130):主机“103.255.6.68”不可用 允许在中连接到此MariaDB服务器 第3行的C:\xampp\htdocs\example\index.php

我的连接字符串是

<?php
//mysqli_connect(host,username,password,dbname,port,socket);
 $con=mysqli_connect('ip','username','password','db_name') or die("Database Error");

if ($con) {
    echo "yes";
}
else {
    die('Could not connect: ' . mysql_error());
}
?>

我在谷歌上搜索并尝试了几乎所有的解决方案,但仍然面临同样的问题。 我正在发布我要连接的pc的一些配置

mysql/bin/my.ini

# The MySQL server
[mysqld]
port= 3306
socket = "C:/xampp/mysql/mysql.sock"
basedir = "C:/xampp/mysql" 
tmpdir = "C:/xampp/tmp" 
datadir = "C:/xampp/mysql/data"
pid_file = "mysql.pid"
# enable-named-pipe
key_buffer = 16M
max_allowed_packet = 1M
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log_error = "mysql_error.log"


# Change here for bind listening
# bind-address="127.0.0.1" 
# bind-address="0.0.0.0" 
# bind-address = ::1          # for ipv6
# Where do all the plugins live
plugin_dir = "C:/xampp/mysql/lib/plugin/" 

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
# 
# commented in by lampp security
#skip-networking
#skip-federated

# Replication Master Server (default)
# binary logging is required for replication
# log-bin deactivated by default since XAMPP 1.4.11
#log-bin=mysql-bin

# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id   = 1

# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
#    the syntax is:
#
#    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
#    where you replace <host>, <user>, <password> by quoted strings and
#    <port> by the master's port number (3306 by default).
#
#    Example:
#
#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
#    MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
#    start replication for the first time (even unsuccessfully, for example
#    if you mistyped the password in master-password and the slave fails to
#    connect), the slave will create a master.info file, and any later
#    change in this file to the variables' values below will be ignored and
#    overridden by the content of the master.info file, unless you shutdown
#    the slave server, delete master.info and restart the slaver server.
#    For that reason, you may want to leave the lines below untouched
#    (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id       = 2
#
# The replication master for this slave - required
#master-host     =   <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user     =   <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =   <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port     =  <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin


# Point the following paths to different dedicated disks
#tmpdir = "C:/xampp/tmp"
#log-update = /path-to-dedicated-directory/hostname

# Uncomment the following if you are using BDB tables
#bdb_cache_size = 4M
#bdb_max_lock = 10000

# Comment the following if you are using InnoDB tables
#skip-innodb
innodb_data_home_dir = "C:/xampp/mysql/data"
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = "C:/xampp/mysql/data"
#innodb_log_arch_dir = "C:/xampp/mysql/data"
## You can set .._buffer_pool_size up to 50 - 80 %
## of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
## Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

## UTF 8 Settings
#init-connect=\'SET NAMES utf8\'
#collation_server=utf8_unicode_ci
#character_set_server=utf8
#skip-character-set-client-handshake
#character_sets-dir="C:/xampp/mysql/share/charsets"
#MySQL服务器
[mysqld]
端口=3306
socket=“C:/xampp/mysql/mysql.sock”
basedir=“C:/xampp/mysql”
tmpdir=“C:/xampp/tmp”
datadir=“C:/xampp/mysql/data”
pid\u file=“mysql.pid”
#启用命名管道
按键缓冲=16M
允许的最大数据包数=1M
排序缓冲区大小=512K
净缓冲区长度=8K
读取缓冲区大小=256K
读缓存大小=512K
myisam\u排序\u缓冲区大小=8M
log\u error=“mysql\u error.log”
#在这里换车
#绑定地址=“127.0.0.1”
#绑定地址=“0.0.0.0”
#绑定地址=::1#用于ipv6
#所有的插件都在哪里
plugin_dir=“C:/xampp/mysql/lib/plugin/”
#根本不在TCP/IP端口上侦听。这可能是一种安全增强,
#如果所有需要连接到mysqld的进程都在同一台主机上运行。
#与mysqld的所有交互都必须通过Unix套接字或命名管道进行。
#请注意,在Windows上使用此选项而不启用命名管道
#(通过“启用命名管道”选项)将使mysqld变得无用!
# 
#由lampp安全部门发表评论
#跳过网络
#跳过联邦
#复制主服务器(默认)
#复制需要二进制日志记录
#默认情况下,自XAMPP 1.4.11以来已停用日志箱
#log-bin=mysql-bin
#1和2^32-1之间所需的唯一id
#如果未设置主主机,则默认为1
#但如果省略,则不会起到主控的作用
服务器id=1
#复制从机(注释掉主节以使用此选项)
#
#要将此主机配置为复制从机,您可以选择
#两种方法:
#
#1)使用“更改主控形状”命令(在我们的手册中有详细说明)-
#语法是:
#
#将MASTER更改为MASTER\u HOST=,MASTER\u PORT=,
#主用户=,主密码=;
#
#替换为带引号的字符串和
#根据主机的端口号(默认为3306)。
#
#例如:
#
#将MASTER更改为MASTER_HOST='125.564.12.1',MASTER_端口=3306,
#MASTER_USER='joe',MASTER_PASSWORD='secret';
#
#或
#
#2)设置以下变量。但是,如果您选择此方法,则
#第一次启动复制(例如,即使未成功)
#如果您在主密码中输入了错误的密码,而从密码无法
#连接),从属服务器将创建master.info文件,以及任何更高版本
#此文件中对以下变量值的更改将被忽略,并且
#被master.info文件的内容覆盖,除非关闭
#删除从属服务器,删除master.info并重新启动从属服务器。
#出于这个原因,您可能希望保持下面的行不变
#(注释)并改为使用更改主控形状(见上文)
#
#2和2^32-1之间所需的唯一id
#(与船长不同)
#如果设置了主主机,则默认为2
#但如果省略,将不起从属作用
#服务器id=2
#
#此从属服务器的复制主机-必需
#主主机=
#
#连接时从属服务器将用于身份验证的用户名
#致船长-必须
#主用户=
#
#连接到时从属服务器将使用的密码进行身份验证
#硕士学位是必修的
#主密码=
#
#主机正在侦听的端口。
#可选-默认为3306
#主端口=
#
#二进制日志记录-从属服务器不需要,但建议使用
#log-bin=mysql-bin
#将以下路径指向不同的专用磁盘
#tmpdir=“C:/xampp/tmp”
#日志更新=/专用目录路径/主机名
#如果使用的是BDB表,请取消注释以下内容
#bdb_缓存_大小=4M
#bdb_最大锁定=10000
#如果您使用的是InnoDB表,请对以下内容进行注释
#跳过innodb
innodb_data_home_dir=“C:/xampp/mysql/data”
innodb_data_file_path=ibdata1:10M:autoextend
innodb_log_group_home_dir=“C:/xampp/mysql/data”
#innodb_log_arch_dir=“C:/xampp/mysql/data”
##您可以将..缓冲区\池\大小设置为50-80%
##但要注意将内存使用率设置得太高
innodb_缓冲区_池_大小=16M
innodb_附加_成员_池大小=2M
##将..日志文件大小设置为缓冲池大小的25%
innodb_日志_文件_大小=5M
innodb_日志_缓冲区_大小=8M
innodb \u刷新\u日志\u在\u trx\u commit=1
innodb\u锁定\u等待\u超时=50
##UTF 8设置
#init connect=\'设置名称utf8\'
#排序规则\u服务器=utf8\u unicode\u ci
#字符集服务器=utf8
#跳过字符集客户端握手
#character_sets-dir=“C:/xampp/mysql/share/charsets”
我已经发布了这个文件中的所有内容,因为我知道我必须更改其中一个文件中的某些内容,
任何帮助都将不胜感激。我已经在这上面浪费了我的一天了

你不必更改这些文件中的任何内容。您需要在数据库上创建一个允许远程访问的用户。MySQL中的帐户基于用户名和IP地址。我的数据库中有一个用户,主机为“%”。它对您尝试执行的操作具有权限吗?请参见此图,此数据库用户具有所有权限。我想我需要为这个数据库和用户添加远程连接,但不知道如何添加。有什么想法吗?