Connecting to remote MySQL Database via 3g 4g problem

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
hrcap
Posts: 131
Joined: Mon Jan 14, 2019 5:20 pm

Connecting to remote MySQL Database via 3g 4g problem

Post by hrcap » Sat Jan 19, 2019 10:34 pm

Evening all

I am in the initial stages of building an app. This app sends SQL queries to a remote MySQL database. When the app is used on the desktop with a wifi connection, or when the app is used on an iOS device with a wifi connection the MySQL query is sent to the database successfully.

When i turn off the wifi on my iPhone and then simply use a 3g or 4g connection the MySQL query will not complete. Has anyone got any input as to why this may be?

As a note the 3g / 4g connection that i am using is good and the amount of data being sent via the connection is very small so i don't think this is occurring due to signal issues.


Many Thanks

ghettocottage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 366
Joined: Tue Apr 10, 2012 9:18 am

Re: Connecting to remote MySQL Database via 3g 4g problem

Post by ghettocottage » Sat Jan 19, 2019 11:20 pm

First guess in troubleshooting this sort of thing is that your database is probably not set to allow connections from IP address outside of wherever your wifi connection is. Your 3g/4g connection is going to have a completely different IP address.

Quick solution would be to set your database to accept any incoming connections, but this is very terrible in practice for any sort of practical application.

A better solution would be to have an intermediate between your database and app. PHP or LiveCode Server works great, and you can customize your connection and pre-write all of your database queries (basically make your own API to connect to)

hrcap
Posts: 131
Joined: Mon Jan 14, 2019 5:20 pm

Re: Connecting to remote MySQL Database via 3g 4g problem

Post by hrcap » Wed Jan 23, 2019 2:11 pm

Thank you very much

This was the issue, I had set access to the server for only a small range of Its. I have added a wildcard username to allow access from any IP and that has solved the problem.


Many Thanks

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Connecting to remote MySQL Database via 3g 4g problem

Post by SparkOut » Wed Jan 23, 2019 7:19 pm

This will have solved your immediate problem but it will introduce another problem in terms of security. Having wildcard access for any device in the world is a very "BAD THING". Much better to build an api to handle posted data for the server to deal with the database interactions. There is another current thread discussing this here viewtopic.php?f=7&t=32028

aber10
Posts: 1
Joined: Tue Mar 12, 2019 11:50 am

Re: Connecting to remote MySQL Database via 3g 4g problem

Post by aber10 » Tue Mar 12, 2019 11:54 am

If I open up a cmd shell and run

>mysql --host=12.34.56.78 --port=1234 --user=myuser --password=mypassword mydb
I can successfully connect to the remote mysql database.

But if I create a php page on my localhost containing

<?php
$hostname = "12.34.56.78:1234";
$username = "myuser";
$password = "mypassword";
$dbname = "mydb";
$connect = mysql_connect($hostname,$username,$password) or die ("Error: could not connect to database");
?>
I get the following error:

Error: could not connect to database
Can anyone explain what might be causing the problem here?

mysql_error() => mysqlnd cannot connect to MySQL 4.1+ using old authentication
Last edited by aber10 on Sun Mar 17, 2019 4:07 pm, edited 1 time in total.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Connecting to remote MySQL Database via 3g 4g problem

Post by FourthWorld » Tue Mar 12, 2019 5:47 pm

aber10 wrote:
Tue Mar 12, 2019 11:54 am
If I open up a cmd shell and run

>mysql --host=12.34.56.78 --port=1234 --user=myuser --password=mypassword mydb
I can successfully connect to the remote mysql database.

But if I create a php page on my localhost containing

<?php
$hostname = "12.34.56.78:1234";
$username = "myuser";
$password = "mypassword";
$dbname = "mydb";
$connect = mysql_connect($hostname,$username,$password) or die ("Error: could not connect to database");
?>
I get the following error:

Error: could not connect to database
Can anyone explain what might be causing the problem here?

mysql_error() => mysqlnd cannot connect to MySQL 4.1+ using old authentication
Where does LiveCode fit into this?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”