how to connect to database on another server

前端 未结 8 1224
孤独总比滥情好
孤独总比滥情好 2020-12-03 02:05

Could I have my php scripts on server A and connect to the MySQL database on server B?

If yes, how it would be done? Thanks in advance

8条回答
  •  情书的邮戳
    2020-12-03 02:37

    Yes.

    The same way you access the localhost on the same server, you change the database host to the external one. This is more a configuration issue, you need to grant your database user remote access to your MySQL, you also need to make sure your firewall allows connections on the MySQL port.

    Example on Debian: http://www.debianhelp.co.uk/remotemysql.htm

提交回复
热议问题