开发者

MySQL database offline for debugging purposes?

I want to debug my PHP program, but it only debugs if the files are offline in the C:/user/local/temp/appdata etc. So I downloaded the whole website onto my computer, but I can't get it to access the database. T开发者_开发技巧he MySQL database is built into the website.

How can I access the MySQL? I desperately need to debug this program.


Ideally, you'll want to create an environment that is almost identical to production (using VMWare or some other VM solution). However, if you're strapped for time, you could connect directly to the remote mysql instance.

MySQL, by default, doesn't listen on any external IPs. So if you want to connect to it, you'll need to modify the MySQL instance on the server to listen on the external IP.

To check it, connect to the server via SSH as root and run:

netstat -nlp | grep mysqld

This will list all of the programs and the ports that they're listening on. For example

tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      818/mysqld
unix  2      [ ACC ]     STREAM     LISTENING     3777     818/mysqld          /var/run/mysqld/mysqld.sock

This means that mysql is only running on 127.0.0.1 (which is not a localhost IP) on port 3306.

You'll need to modify /etc/my.conf or /etc/mysqld/my.cnf and edit:

bind-address        = 0.0.0.0

Listen on all interfaces.

Then restart mysqld:

/etc/init.d/mysqld restart

Now you should be able to confirm that mysqld is listening on the external IP with netstat and you should be able to connect to it from your remote computer.

HTH

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜