I am experiencing a very slow ADO and mysqli connection for my production web server. The current software setup is windows 2008 server R2 Standard Edition SP1, Apache 2.4, PHP 5.3.10, MySql 5.5.24, Pear 1.94, Zend Engine version 2.30.
I've profiled the code using XDEBUG and it shows the initial connections taking around 1200ms each (regardless of page being visited), whereas on my local development machine and another test server the connections only takes around 8ms. The code for the website is all in sync through SVN except for the php, pear, mysql, and apache ini and conf files. I've done diffs on these to check for differences and there aren't any. The DB contents are a complete copy as well. Everything for the production server is hosted on the same machine so there aren't any firewall or internet issues.
The first connection profile has the following call stack:
ADOConnecton->Connect
ADODB_mysql->_connect
php::mysql_connect
The second one:
php::mysqli->mysqli
Any suggestions?
Usually the slowness in (first) connection depend on DNS resolution.
May be:
client to resolve the server name
server to resolve the client name to match an access rule
let the client/server let know the server/client address using the host file:
http://en.wikipedia.org/wiki/Hosts_(file)
I edited the Mysql my.ini to change the mysql service to only bind to the IPV4 loopback adapter.
[mysqld]
...
bind=127.0.0.1
I also changed the \public_html\conf\face.ini to use the IPV4 loopback address instead of local host. (Changed "localhost" to "127.0.0.1")
After that all issues went away. I'm not sure if it is because the machine has a half dozen IP addresses or its trying to decide whether to use IPV6 or IPV4.
Related
I am in the process of moving from PHP 5.6 to PHP 7.
I have a virtual machine running PHP 5.6 (PHP5) with MySQL running on it. The code is mounted from my host.
I have a second virtual machine running PHP 7 (PHP7). The code is also mounted from my host. All of my projects are configured with "localhost" as the database host.
As the first step, I want to have the MySQL "localhost" on PHP7 go directly to the PHP5 MySQL instance.
I have setup an ssh tunnel such that port 3306 on PHP7 goes directly to 3306 on PHP5, but this doesn't seem to help (EDIT: although if I change the config in a project to have a 127.0.0.1:3306 host it does work, but the host change is what I'm wondering whether I can avoid :) ).
Is there a way to setup the forwarding so that the projects will just work (or not), or do I need to go through each project and update it to cope with both servers?
I am creating an application with Laravel and Firebird 2.5 and wants to run it on a DigitalOcean server structure. We have 2 servers for the application, one for the web services (lets call it www) and one for the database services. I did a successful setup with Mysql and it works well but we all know Firebird is a rough one. So this is what we did so far:
Install a LEMP stack in www and Firebird 2.5 SuperServer. As I said these are digital ocean servers, both runs Ubuntu 14.04.
We created an SSH tunnel between the two server with the following structure:
ssh -L 9500:127.0.0.1:3050 username#db_server_ip_address (Private address)
But when we tried to hook up the application on www with the database server got the following error:
unavailable database
In the Laravel Configuration file used the following set up:
DB_HOST=127.0.0.1
DB_DATABASE=/home/username/database.gdb
DB_USERNAME=username
DB_PASSWORD=password
The credentials are correct, we can use it on the remote (db) server.
What do you think what could be the problem? Is it the SSH tunneling?
Warning: I don't use SSH that much, and have never used SSH tunneling, my answer is based on looking at documentation.
The ssh -L 9500:127.0.0.1:3050 does not do what you think it does:
Specifies that connections to the given TCP port or Unix socket on the local (client) host are to be forwarded to the given host and port, or Unix socket, on the remote side. This works by allocating a socket to listen to either a TCP port on the local side, optionally bound to the specified bind_address, or to a Unix socket. Whenever a connection is made to the local port or socket, the connection is forwarded over the secure channel, and a connection is made to either host port hostport, or the Unix socket remote_socket, from the remote machine.
(from ssh(1))
In other words, as far as I can tell the proper command would be:
ssh -L 9500:<ip-address of the Firebird server>:3050
The second problem seems to be that your Laravel config does not specify a port, so it is likely still trying to connect to port 3050 (the Firebird default port), instead of port 9500 that you configure. I don't know Laravel, but a property DB_PORT=9500 seems logical (but maybe these properties are specific to your own deployment, in which case you may need to do some more work).
I am new to working with servers, and am not able to use SQLYog because it is not able to connect to any server. When I try to use the default values to connect to MySQL (localhost, root, port 3306), I get "Error No. 2003: Can't connect to MySQL server on 'localhost' (0).
Is there something I am missing or that I have to correct? I am just trying to create a database.
SQLyog is just one way to connect to a MySQL database and interact with it. Other popular methods include MySQL Workbench, Navicat, phpMyAdmin, and others.
Before you can use any of these, you have to first make sure your MySQL server is running and accepting connections. You didn't mention (or tag) whether you are running MySQL on your local machine, or what operating system you are using.
A couple of the most common development environments are LAMP or WAMP, for "Linux, Apache, MySQL, php" or "Windows, Apache, MySQL, php" respectively. Since you tagged your question php, I'll assume one of these is appropriate. (For example you're using SQLyog on Windows but your MySQL server is on Linux.) (I'll presume Ubuntu for Linux examples.)
On the machine you've installed MySQL (along with any other components), you should be able to determine its running state by looking at your process list (ps aux in Ubuntu, tasklist or Task Manager (GUI) in Windows).
You're looking for mysqld (Linux) or mysqld.exe (Windows). If the process isn't running, you need to start it (Linux/Windows). If you're using WampServer (a popular Windows all-in-one package), for example, you can also look in your Windows Services for "wampmysqld" or "wampmysqld64" and start the service there.
If you can't get the process to start, you may have a configuration error. If the process is running, you may need to check the configuration any way to determine what port it is running on, if it's not the standard 3306.
The configuration file name and location can vary by system and package, but generally it will be called "my.cnf" (Linux) or "my.ini" (Windows). Check your documentation for help on the specific path.
Once you've got the service running, you should be able to connect!
This is the default SQLyog connection dialog (at least in my slightly older version). The defaults assume you are running your MySQL server on your local machine (localhost), that you have a user "root" with no password, and the default port 3306 is used.
You'll need to change any of this information that differs on your particular installation.
Be aware that if you're trying to connect to an instance of MySQL on another machine, a firewall may be blocking a port.
These steps should hopefully get you on the right track.
Hi I am now into something that keeps confusing me. The problem i have is that i transfer my Domain DNS into a Linux Hosting because of massive attacks, Before i was running my website into a xampp Apache for Windows. i put a Anti Ddos Software but it can't really mitigate the server attack everyday. until yesterday that we discovered that we have a 100 Million Attacks filtered by the Main Firewall. and our firewall gives up.
to make the story short i transfer my Website files into a Linux Apache Server to another hosting... but the MYSQL server stays on my Windows Server. i also change the port of MySQL server into something not related to the default 3306.. i made it 4444. the reason why i don't transfer MySQL is because this MySQL is connected into My Private Hosting of a Game. now all i want is to access the MySQL from Linux Hosting using PHP. Here is My Current Code for Connection
I paste into text file in my website here is the Link
Note: I allow all Ports that is Necessary from Remote Connection, And i Close the Port 80 to Prevent Server attack..
Thanks in advance for the help...
I developed a PHP application with MySQL and node.js implementation.
I am trying to connect to my production DB like the following:
mysql_connect('54.212.117.38', 'root', '********');
This is the Error I get :
Could not connect: Can't connect to MySQL server on '54.212.117.38' (4)
I must mention that I can reach the PHPmyAdmin directly through the browser.
Moreover, On local host the application is connecting to MySQL with no problem.
I also tried restarting the Apache server, shutting down the Node.js procedure...
BTW - My production server is running Ubuntu.
Does anyone has an idea on what's the reason that it doesn't work?
There is more than one possibility. Some advice:
Make sure the mysql server behind this IP address is running and accepting connects.
Make sure the user can access from your clients ip.
Check out if perhaps the connection process takes too long (in this case, you can try increasing the connect_timeout).
If nothing else helps, trace the traffic between client and server. Maybe a firewall is slightly too aggressive (I've had that once, user root was triggering an IDS rule...).
A sidenote, the mysql extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used.
the problem is the firewall rules.
When you connect via Phpmyadmin, you are connecting through the web interface and internally Phpmyadmin is connecting to localhost.
Check your local ip or the ip of the server that you want to connect from.
Make sure you change the parameter bind-address to:
bind-address = 0.0.0.0 = 0.0.0.0