I got following error:
Warning: mysqli_connect(): (HY000/2003): Can't connect to MySQL server
on 'x.x.x.x' (111) in
/srv/disk1/2141710/www/vetalpallavi21.eu.pn/connection.php on line 7
Connection failed: Can't connect to MySQL server on '83.125.22.219'
(111)
I am hosting a site using free web hosting servers I don't know the IP address of that host server.So what should I give the first parameter in mysqli_connect() query and how can I get the IP address of that host.
If the server has mysql configured correctly you can use "localhost" instead of the IP address.
// use 172.0.0.1 OR "localhost"
$connection = mysqli_connect("127.0.0.1", "username", "password", "dbname");
// localhost:
$connection = mysqli_connect("localhost", "username", "password", "dbname");
the login details(username/password) are often emailed to you.
I am sure that information is included in the registration email. They send username and password along with php my admin login.
If that is the IP of the website you signed up at it's most likely not their SQL server(s).
PS: I am not sure if it's against stackoverflow TOS but it would be best if you don't show IPs for security and privacy :)
Related
Trying to set up and host a db on Bluehost but having issues when testing it locally. Setting connection string as $link = mysqli_connect("localhost", "username", "password", "dbname")
`
but I keep getting "No connection could be made because the target machine actively refused it".
I should note that I'm setting the database as a remote connection.
It seems permission is granted, try to grant the permission first. Here "%" mean Db can accept the connection from any IP, if you want to make DB can accept the connection from specific hostname for IP then instead of "%" use the hostname or IP.
GRANT ALL PRIVILEGES ON dbname.* TO 'username'#'%';
I try to connect my android application using JSON Parser to the web hosting. But whenever I try to connect (even just open using url in the browser) I will get the error message.
<?php
$dbHost = 'http://sql4.000webhost.com/localhost';
$dbUser = 'a6410240_cbetTD';
$dbPass = 'xxxxxx';
$dbName = 'a6410240_cbetTD';
$conn = mysql_connect ($dbHost, $dbUser, $dbPass) or die ('MySQL connect failed. ' . mysql_error());
mysql_select_db($dbName,$conn);
?>
This is my database.php file. The full error message is
Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'http' (4) in /home/a6410240/public_html/database.php on line 8.
I have tried change the $conn but still it didn't worked for me.
Thanks
If your database and application is on same server then use "locahost" in $dbhost.
And if your database and application is on different servers then you need to use IP address or hostname in $dbhost and the database user should be added on database server provided with required privileges.
The problem you are having was already mentioned in one of the comments, this one to be precise.
For your solution to work, all you need to do is omit the part http:// at the beginning and probably /localhost at the end.
The host is only the domain you are referring to. In this case sql4.000webhost.com. With /localhost you tried to already connect to a database, although your configured database is supposed to be a6410240_cbetTD.
MySQL use TCP port 3306 by default
($dbport) and hostname or IP address ($dbhost). For LAMP (Linux-Apache-MySQL-php) you can find a lot of tutorials.
Usually MySQL server listens internal port (which can't be reached via Internet) for security purposes.
If you familiar with docker, you can simply download examples of LAMP solutions from hub.docker.com.
I have recently installed a SSL certificate on my website.
This has caused some issues which I was not expecting at all.
The issue that I have right now is that I cannot connect to the MySQL database!
My connection file is like this:
<?php
$db_conx = mysqli_connect("Mydomain.com", "mystore", "Mypassword", "mystore");
// Evaluate the connection
if (mysqli_connect_errno()) {
echo mysqli_connect_error();
exit();
} else {
echo "";
}
?>
The code above was working perfectly fine before I installed the SSL but it has stopped connecting to the MySQL database since I installed the SSL.
if I change the
$db_conx = mysqli_connect("Mydomain.com", "mystore", "Mypassword", "mystore");
to
$db_conx = mysqli_connect("localhost", "mystore", "Mypassword", "mystore");
It starts working again but I need to use the domain name same as before as I will need it to connect to a remote MySQL database.
Once again, this was working just fine before I installed the SSL.
Could someone please advise on this and what needs to be done to resolve this issue?
Thanks
try the connection with port
$db_conx = mysqli_connect("Mydomain.com:3306", "mystore", "Mypassword", "mystore");
Your hosting company might have changed/added IP address(es) to your machine, as traditionally certificates demanded their own IP address. Usually a hosting company would just add an extra IP address to your web server machine, on top of the IP address you already had.
Now if your PHP script uses the new IP address to connect to the MySQL server, your MySQL server might not recognize the new IP, and reject the connection.
Ask your hosting company to either set the former IP address as the one that PHP uses to connect to MySQL. Or ask them to set a route to the MySQL server via the former IP.
Or you can just check if you have enough privileges to change the IP address that the MySQL server grants access to.
there's this server:
http://phpmyadmin.pvdata.fr/index.php ,
I can connect to it knowing the username and password and Server Choice.
Once I connect to it, it shows under MySql the following information: (I'm Translating from French)
Server: sql6 (sql6 via TCP/IP)
Server Version: 5.0.92-87
Protocol Version: 10
Username: pvdata#10.5.1.3
Character for MySql: UTF-8 Unicode (utf8)
So I tried using the following code in order to connect to the Database:
<?php
// Create connection
$username = "pvdata";
$password = "xxxxxxxx";
$hostname = "10.5.1.3";
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
?>
But it didn't work, it's saying: "A connection attempt failed because the connected party did not properly respond after a period of time".
What am I doing wrong?
Go to your phpMyAdmin installation and look for the file config.inc.php. Open that file, and check which hostname / ip is being used for SQL6. That is the IP you should use for your mysql_connect()
This is most likely a firewall issue. Most 3rd party hosts don't allow you to access MySQL from 'the outside'.
You can do this if you manage the MySQL server yourself or if you have a host that doesn't deny you to access the database from another machine, but in regular web hosting, this is not common.
You need to search, google helps a lot, also you need to connect to an ip/domain and port of your MySQL server.
For this, you need to know what is the port of your mysql server.
Look this answer from link
<?php
mysql_connect("mysite.com:3306", "admin", "1admin") or die(mysql_error());
echo "Connected to MySQL<br />";
?>
to check if you have coneccion, try in console:
shell> mysql --host=remote.example.com --port=3306 //3306 is the
defaul port for MySQL
http://dev.mysql.com/doc/refman/5.0/en/connecting.html
I want to ask about how to connect my localhost application (C:xampp/htdocs/myproject) to database at my server host (www.someweb.somedomain)?
Am I possible to do that? If it is, how to connect it at my php config? Right now my config (server.php) is:
<?php
$host = "my web IP public:3306";
$user = "root";
$pass = "";
$db = "dispatcherDB";
$conn = mysql_connect($host, $user, $pass) or die ("Cant connect to mySQL");
mysql_select_db($db);
?>
what I got:
Warning: mysql_connect(): No connection could be made because the target machine actively refused it. in C:\xampp\htdocs\XMS\server.php on line 7
So, what must I filled for $host? I'm trying using website IP, it still can't connect. Maybe there's someone here have experience at this problem?
Sorry for my bad English
If you have cPanel access to the remote server then you need to mention that from which ip addresses it should allow access to MySQL..
In cPanel you will get Remote MySQL under heading Databases:
Clicking Remote MySQL will give you the option to add hosts from where you want to allow connections to your MySQL server:
Also, you can check localhost without specifying port number as value of $host..
Probably Mysql server is not allowed root access from remote servers.
you could check this post