Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2003):
Can't connect to MySQL server on '209...' (13) in
/home/www/hookahondemond.com/Sendorder01010101010101.php on line 77
Failed to connect to MySQL: Can't connect to MySQL server on
'209...' (13)
my php code
<?php
$con=mysqli_connect("209.17.116.155","mir****","M****6","stores",'3306');
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
Login to Apache/PHP server and make sure that you can connect to the MySQL port:
telnet <mysql host> <mysql port>
If you cannot telnet the port, then it could be either one of these:
a network (firewall? routing?) problem
your MySQL server is currently not running
your MySQL host/port is incorrect
your MySQL is running but does not accept tcp connections (it has --skip-networking option set)
If you can telnet the MySQL host/port, then there is no network/MySQL setting problem,
and actually, you should be seeing a different error message (like credential error)
Related
<?php
$conn = new mysqli('localhost','root', '', 'votesystem','8080');
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
Errors returned are:
Warning: mysqli::__construct(): Error while reading greeting packet. PID=14576 in
C:\xampp\htdocs\votesystem\admin\includes\conn.php on line 2
Warning: mysqli::__construct(): (HY000/2006): MySQL server has gone away in
C:\xampp\htdocs\votesystem\admin\includes\conn.php on line 2
Fatal error: Maximum execution time of 120 seconds exceeded in
C:\xampp\htdocs\votesystem\admin\includes\conn.php on line 2
My localhost runs on port 8080.
username-root
hostname=localhost
password=no
global privileges=ALL
PRIVILEGES Grant= yes
You have confused the Webserver with the MySQL Server. Your web server is running on port 8080, not your MySQL Server. The MySQL server runs on port 3306 (by default) so your web application needs to connect to it on that port.
Change your mysqli connect string to:
$conn = new mysqli('localhost','root', '', 'votesystem', '3306');
I have install mysql on digital ocean and trying to connect through php script and I got this error
mysqli_connect(): (HY000/2002): Connection refused in
/var/www/waev.in/signup/ajax/send_code.php on line 9 Failed to connect
to MySQL: Connection refused
What can be the issue :
my php script
<?php
include '../func/sms_function.php';
$mysql_host='{ip}';
$mysql_user='root';
$mysql_pass='********';
$my_db='wesearch_waev_user';
$con = mysqli_connect($mysql_host,$mysql_user,$mysql_pass);
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
Maybe this would be
$mysql_host="localhost";// for local server
Or
$mysql_host="$ip";// if database is in remote and IP is stored in $ip
Check the port you are using on the server. MySQL needs to be running on the port 3306
I have a database hosted by one.com with these settings:
PhpMyAdmin: https://dbadmin.one.com
Host: axelerate.be.mysql
Database: axelerate_be
Username: axelerate_be
Password: *****
I want to make connection with this database by using a php file runned by the LXTerminal of the raspberry pi. When i try to make connection i get this error (host unknown):
Warning: mysqli_connect(): php_network_getaddresses: getaddrinfo
failed: Host is onbekend. in C:\xampp\htdocs\twitter\index.php on line
3
Warning: mysqli_connect(): (HY000/2002): php_network_getaddresses:
getaddrinfo failed: Host is onbekend. in
C:\xampp\htdocs\twitter\index.php on line 3 Failed to connect to
MySQL: php_network_getaddresses: getaddrinfo failed: Host is onbekend.
This is my code:
<?php
// Create connection
$con=mysqli_connect("axelerate.be.mysql","axelerate_be","*******","axelerate_be");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}else{
echo "it works!";
}
?>
My question:
How can i make this connection work without edditing any config files? (so if there is something to do, I want only to write in the php file)
Thanks!
The .mysql based hosts are internal hosts within the one.com network that resolves to the server that hosts your database. These hosts are not meant for connections outside of one.com hosting, and probably doesn't accept connections from the world if they're even available on a public IP.
Make sure the host (axelerate.be.mysql) exists, try to ping it. AS i can see it doesnt exist.
One.com doesn't support mysqli. You have to use
$db=mysql_connect("example.com.mysql", "username", "password");
mysql_select_db("database", $db);
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select
I tried to connect mysql database.but am getting the following error.
Warning: mysql_connect(): [2002] No connection could be made because the target machine actively (trying to connect via tcp://localhost:3306) in test.php on line 5
Warning: mysql_connect(): No connection could be made because the target machine actively refused it. in test.php on line 5 Warning: mysql_close() expects parameter 1 to be resource, boolean given in test.php on line 15
test.php:
<?php
$link = mysql_connect(localhost, dbuser, dbpass);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
This happened to us when running a PHP & MySQL on IIS7 in Windows Server 2008 in VirtualBox. It turns out that the Windows hosts file didn't have an IPv4 entry for localhost (127.0.0.1) so the route to MySQL on localhost was not found.
We added the following to the hosts file which resolved it:
127.0.0.1 localhost # Additional IPv4 entry
::1 localhost # Existing IPv6 localhost entry
Reference: A brief description of PHP/MySQL Localhost via IPv4 & IPv6
The MySQL server isn't running, or you have a firewall blocking port 3306.
This error message means the system did not accept the TCP connection request.
In my.ini find string:
bind-address = 127.0.0.1
Change from localhost to network IP.
Got the same message trying to connect to 'localhost' by mistake (on a Windows server). After fixing the connection string to the correct (remote) server the error disappeared.
EDIT: I just realized that this question may be better suited to ServerFault. Instead of copying it, a moderator please move it over? Thanks.
I've checked php-info, and the Postgresql extension is there (pg_connect() is not undefined). I am also able to connect to postgresql using psql on localhost (I've edited my pg_hba.conf file appropriately). Here is the code that's not working:
<?php
$dbconn = pg_connect("host=localhost port=5432 dbname=mydb user=myuser password=mypass") or die('Could not connect: ' . pg_last_error());
?>
This code simply results in "Could not connect: " being displayed in the browser.
I checked my apache log, and here's the relevant error message:
PHP Warning: pg_connect() [<a href='function.pg-connect'>function.pg-connect</a>]:
Unable to connect to PostgreSQL server: could not connect to server: Permission
denied\n\tIs the server running on host "localhost" and accepting\n\tTCP/IP
connections on port 5432?
How can I fix/debug this?
Edit: I'm on Centos 5.4 btw.
could not connect to server: Permission denied
Edit: I'm on Centos 5.4 btw.
Check /var/log/audit/audit.log. Chances are that you're hitting a SELinux rule.