Connecting to a remote database from a localhost computer using mysql and PHP

后端 未结 2 932
执念已碎
执念已碎 2020-12-17 03:01

So here is the situation. I have a database on a remote server that gives out quizzes and scores for individual students...

I also have a local database which contai

相关标签:
2条回答
  • 2020-12-17 03:28

    https://documentation.cpanel.net/display/ALD/Remote+MySQL# I found useful this one myselt. When you haven't define access permissions to remote db using it's cpanel, then you cannot connect with it via the localhost from your PC.

    You will find something like 'Add Access Host' in your hosting server cpanel and there you can add which IPs are you going to use to access from outside. There I used as "%.%.%.%" and that means I allowed every v4 IPs to access my database. Instead of "%.%.%.%" you can put your PC's IP(for example 51.254.230.178). As PC's IP gets changed frequently, then I used this because I cannot change it manually all the time by checking my IP every time I connected to the Internet.

    0 讨论(0)
  • 2020-12-17 03:38
    GRANT ALL ON database.* TO user@ipaddress IDENTIFIED BY 'password';
    

    You should force a reload of the grant tables using:

    FLUSH PRIVILEGES;
    
    0 讨论(0)
提交回复
热议问题