473,624 Members | 2,612 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Remote MySQL Server

I have a script on one server, trying to access the MySQL database on
another server. The server with the script is on an outside network,
hosted with another company. The MySQL server is here in the
office;behind a firewall. Script works fine when it is on the local
machine, but when I moved it to the offsite webserver it gives me:

Warning: mysql_connect() [function.mysql-connect]: Lost connection to
MySQL server during query in /directory/directory2/functions/
shared_data_con nections.php on line 29
Unable to connect to database.

The script is:

$username = "user";
$password = "password";
$hostname = "ip_address ";
$database = "database";

$connection = mysql_connect($ hostname, $username, $password)
or die ("Unable to connect to database.");
$open = mysql_select_db ($database, $connection)
or die ("Unable to select database.".mysq l_error());
return $connection;

One obvious problem could be the firewall. But since making any
adjustments to the firewall is frowned upon around here, I want to
cover some other bases first. Want to get some evidence that it
probably isn't something else. Any other ideas? I am very certain that
the user/pass are correct and that is the correct IP address. I have
also made certain that the user has access from any host.

Aug 14 '07 #1
4 3894
Forgot to mention that the server with MySQL on it, the one inside the
office, uses SSH for connectivity.

Aug 14 '07 #2
On Aug 14, 3:18 pm, Jerim <wyo...@gmail.c omwrote:
I have a script on one server, trying to access the MySQL database on
another server. The server with the script is on an outside network,
hosted with another company. The MySQL server is here in the
office;behind a firewall. Script works fine when it is on the local
machine, but when I moved it to the offsite webserver it gives me:

Warning: mysql_connect() [function.mysql-connect]: Lost connection to
MySQL server during query in /directory/directory2/functions/
shared_data_con nections.php on line 29
Unable to connect to database.

The script is:

$username = "user";
$password = "password";
$hostname = "ip_address ";
$database = "database";

$connection = mysql_connect($ hostname, $username, $password)
or die ("Unable to connect to database.");
$open = mysql_select_db ($database, $connection)
or die ("Unable to select database.".mysq l_error());
return $connection;

One obvious problem could be the firewall. But since making any
adjustments to the firewall is frowned upon around here, I want to
cover some other bases first. Want to get some evidence that it
probably isn't something else. Any other ideas? I am very certain that
the user/pass are correct and that is the correct IP address. I have
also made certain that the user has access from any host.
My immediate thought, and this is more of a shot in the dark than
anything, but are you specifying the correct port number. It wouldn't
be an issue if you were on a local machine, but if you are connecting
to a remote host they might have MySQL running on a different port,
not to mention the SSH connection. If that doesn't help, I googled
this article which may be helpful:

http://blog.taragana.com/index.php/a...ing-query-fix/

Good luck!

Aug 14 '07 #3
On Aug 14, 3:39 pm, burgermeiste... @gmail.com wrote:
On Aug 14, 3:18 pm, Jerim <wyo...@gmail.c omwrote:
I have a script on one server, trying to access the MySQL database on
another server. The server with the script is on an outside network,
hosted with another company. The MySQL server is here in the
office;behind a firewall. Script works fine when it is on the local
machine, but when I moved it to the offsite webserver it gives me:
Warning: mysql_connect() [function.mysql-connect]: Lost connection to
MySQL server during query in /directory/directory2/functions/
shared_data_con nections.php on line 29
Unable to connect to database.
The script is:
$username = "user";
$password = "password";
$hostname = "ip_address ";
$database = "database";
$connection = mysql_connect($ hostname, $username, $password)
or die ("Unable to connect to database.");
$open = mysql_select_db ($database, $connection)
or die ("Unable to select database.".mysq l_error());
return $connection;
One obvious problem could be the firewall. But since making any
adjustments to the firewall is frowned upon around here, I want to
cover some other bases first. Want to get some evidence that it
probably isn't something else. Any other ideas? I am very certain that
the user/pass are correct and that is the correct IP address. I have
also made certain that the user has access from any host.

My immediate thought, and this is more of a shot in the dark than
anything, but are you specifying the correct port number. It wouldn't
be an issue if you were on a local machine, but if you are connecting
to a remote host they might have MySQL running on a different port,
not to mention the SSH connection. If that doesn't help, I googled
this article which may be helpful:

http://blog.taragana.com/index.php/a...sql-server-has...

Good luck!
I also found that when you setup MySQL, you can set it up to use
either TCP connections or shared memory. In this case, it is using
shared memory, so no TCP connection would ever work. I have found a
solution that works. Basically, I have an include file on the MySQL
server, that is used by the webpage on the remote server. All the SQL
code is in the include, which is local to the MySQL database.

Aug 14 '07 #4
C.
On 14 Aug, 22:38, Jerim <wyo...@gmail.c omwrote:
On Aug 14, 3:39 pm, burgermeiste... @gmail.com wrote:
On Aug 14, 3:18 pm, Jerim <wyo...@gmail.c omwrote:
I have a script on one server, trying to access the MySQL database on
another server. The server with the script is on an outside network,
hosted with another company. The MySQL server is here in the
office;behind a firewall. Script works fine when it is on the local
machine, but when I moved it to the offsite webserver it gives me:
Warning: mysql_connect() [function.mysql-connect]: Lost connection to
MySQL server during query in /directory/directory2/functions/
shared_data_con nections.php on line 29
Unable to connect to database.
<snip>
One obvious problem could be the firewall. But since making any
adjustments to the firewall is frowned upon around here,
! of course its frowned upon but you need to work out what the problem
is before you worry whether or not it needs to be changed.

Really this is not a PHP question - try using the MySQL command line
interface. The error suggests that PHP is able to conect to the server
but subsequently loses the connection - in which case its not simple
port blocking (AFAIK, unlike FTP, MySQL uses a single connection from
client to server).

I'd suggest you sit down with your local friendly network admin
(ignoring the oxymoron) the mysql cli tool and a copy of wireshark and
see if you can replicate the error.

C.

Aug 15 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2285
by: hera | last post by:
I am new at php and MySQL and have some (ugly, I'm sure) code to populate form select fields with data from a MySQL database, so a user can use those to sort/filter and view the 3,000 records. No inserts -- just selects; very simple. I originally set this up using URL-based query strings at http://stjuliana.org/school/ar/BUindex.php but since that only allowed sorting and not filtering, hence all 3k records load, I made a form verson...
3
2510
by: JStrummer | last post by:
I have a mySQL database located on a remote host's server. I would like to schedule a task on my local Windows computer to retrieve a backup/dump of this remote database. I have contacted my host, and they indicated that the server is only open to the Internet via mySQL. Therefore, even if I did have access to that server's command line (which I don't) to create dumps via mysqldump, I would not be able to retrieve via FTP. Does...
4
8406
by: Ian Davies | last post by:
Hello all The following code allows me to connect to a local MySQL database on my pc from a VB6 project. **************************************************************************** ** Dim conn As ADODB.Connection Dim cs As String Dim MyServer As String
7
2491
by: Ike | last post by:
Let's say I have a MySQL 4.12 database, opened to the internet on 111.111.111.111 allowing all incoming and outgoing ports. I have a username and password setup, which CAN connect to this database, from 222.222.222.222. Also on 222.222.222.222, which is running Tomcat, I have a Java servlet, called, say, servlet.class in WEB-INF/classes. servlet.class has permissions 755, as does WEB-INF/classes. Additionally, I have on...
4
2666
by: courtney.machi | last post by:
Hello, I am trying to connect to a remote mysql server through php. Here's the code: mysql_connect("my.hostname.edu", "username", "password") or die (mysql_error()); mysql_select_db("db_name") or die ("unable to select db".mysql_error()); $r1 = mysql_query('SELECT * FROM table') ;
2
22534
by: Martin | last post by:
Hi all. I have a fully functional page hosted on my PC that uses PHP and connects to MySQL on my PC to generate it's code. I now have some web hosting available which includes both PHP and MySQL support, however the webhost is still in the process of getting the MySQL support activated and functional. I therefore have uploaded my webpage to the host and edited the webpage
2
5937
by: dronkanoki | last post by:
I am attempting to set up myODBC 3.51 on Win XP Pro to a remote MySQL Linux server. I get the following error: Access denied for user: 'username@ipaddress.serviceprovider.net' (Using password: YES) I had MySQL installed locally for testing, and myODBC worked fine. All the other apps I use locally (Dreamweaver, PHPmyAdmin, MySQL Front) work great on the remote server with the same login info. This is my thought (patience, please). My...
1
30568
by: mcyi2mr3 | last post by:
hi all how do i make a command line connection to a remote mysql server? for local connections i know it is: mysql -u root dbname how do i connect to a remote server with a password? thanks marc
4
2034
by: Pseudonyme | last post by:
A Paris Le 14 Nv MMVII Dear Madam and Sir, Do you know how to access a MYSQL DB from an external server ? We read the information and studied :
0
8179
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7174
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4184
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.