简体   繁体   English

如何在htdocs文件夹之外访问XAMPP mysql数据库

[英]How to access XAMPP mysql database outside of htdocs folder

I need to access the MySQL server from my local website located outside of htdocs folder. 我需要从位于htdocs文件夹之外的本地网站访问MySQL服务器。 When I enter XAMPP server credentials, it shows: 输入XAMPP服务器凭据时,它显示:

NO FILE OR ROOT DIRECTORY FOUND

Is there some config settings I can change in XAMPP's config file to allow access? 我可以在XAMPP的配置文件中更改某些配置设置以允许访问吗?

In order to connect remotely you have to have MySQL bind port 3306 to your machine's IP address in my.cnf. 为了远程连接,您必须使MySQL将端口3306绑定到my.cnf中计算机的IP地址。 Then you have to have created the user in both localhost and '%' wildcard and grant permissions on all DB's as such . 然后,您必须同时在localhost和'%'通配符中创建用户,并在所有DB上授予权限。 See below: 见下文:

my.cnf (my.ini on windows) my.cnf(在Windows上为my.ini)

#Replace xxx with your IP Address 
bind-address        = xxx.xxx.xxx.xxx

then 然后

CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass';
CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypass';

Then 然后

GRANT ALL ON *.* TO 'myuser'@'localhost';
GRANT ALL ON *.* TO 'myuser'@'%';

Depending on your OS you may have to open port 3306 to allow remote connections. 根据您的操作系统,您可能必须打开端口3306才能允许远程连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM