how to access cpanel database access in godady server using mysql php connectivity
i have tried a lot but last long it gives me
Warning: mysql_connect() [function.mysql-connect]: Lost connection to
MySQL server at 'reading initial communication packet', system error:
111 in /home/content/q/u/i/quickandkosh/html/searchdata.php on line 6
Could not connect: Lost connection to MySQL server at 'reading initial
communication packet', system error: 111
I'm not sure about go daddy but I know some web hosts need a specific path to mysql server. Most us localhost but others, such as ipage use a full path through the virtual server. Go into your cpanel at godaddy and then "mysql databases" and it should have a "server" title with address below it somewhere in the page.
Just to note, you should also be using mysqli_connect.
I think your host could be wrong, wrong port, a firewall blocked the connection. So I would double check your connection settings.
Related
I have installed XAMPP on windows 10 but cannot open phpMyAdmin. I had to change Apache port 443 to 4433 because of conflicts and now both apache and mysql are running. When I click on phpMyAdmin on my server it gives me the following message in a pink box:
MySQL said: Documentation
Cannot connect: invalid settings.
mysqli::real_connect(): (HY000/2002): No connection could be made because the target machine actively refused it.
Connection for controluser as defined in your configuration failed.
mysqli::real_connect(): (HY000/2002): No connection could be made because the target machine actively refused it.
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
I've read the questions on similar problems but they mostly happened when someone changed the password, but for my case, the user is set to root and the password is empty both in MySQL server connection and in the config.inc.php file. I have no clue where to look for the problem.
What version is your XAMPP? Try going to task manager, locate mysqlI and end task. Now close the XAMPP window and open it again. Go to Mysql and try test the connection by connecting to the database on port 3306. If it gives en error check the error log in the XAMPP.
it shows the following errors :-
mysqli_real_connect(): (HY000/2002): A socket operation was attempted
to an unreachable host.
Connection for controluser as defined in your configuration failed.
mysqli_real_connect(): (HY000/2002): A socket operation was attempted
to an unreachable host.
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
This error indicates that the network was not connected or not configured correctly. It is definitely an error on the client machine, not your server.
There isn't much you can do to "solve" the problem. Pretty much all you can do is upgrade the client's network drivers and check for connection problems (maybe they're barely within wireless range, or the Ethernet cable is missing its locking tab).
I have a MySQL database in a 3rd party server. I am trying to access it from my local machine using PHP in Dreamweaver. However, I am getting the following error:
MySQL Error #2002:
A connection attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because connected host
failed to respond.
Thank you.
It means you can't connect to the server. Check your connecting to the correct IP address and your firewall is configured to allow traffic.
If your using "localhost" also try host name as 127.0.0.1. If its server try from mysql terminal whether that host is connecting from your local machine.
In local machine I have faced same issue with host localhost and changed to 127.0.0.1 then its works well.
I have the following PHP code to connect to my db:
<?php
ob_start();
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
?>
However, I get the following error:
Warning: mysql_connect() [function.mysql-connect]: [2002] A
connection attempt failed because the connected party did not (trying
to connect via tcp://localhost:3306) in C:\Program Files (x86)\EasyPHP-
5.3.2i\www\checklogin.php on line 11
Warning: mysql_connect() [function.mysql-connect]: A connection
attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because
connected host has failed to respond. in C:\Program Files (x86)\EasyPHP-
5.3.2i\www\checklogin.php on line 11
Fatal error: Maximum execution time of 30 seconds exceeded in
C:\Program Files (x86)\EasyPHP-5.3.2i\www\checklogin.php on line 11
I am able to add a db/tables via phpmyadmin but I can't connect using PHP.
Here is a screenshot of my phpmyadmin page:
What could be the problem?
Check the following:
Is MySQL running?
Is there any firewall that could be blocking your computer from accepting connections to MySQL on port 3306?
Is MySQL listening on port 3306, or did it get changed to something nonstandard?
An odd one, but try changing from localhost to 127.0.0.1
Basically, the errors you're getting mean that it cannot connect to the server. It sends request to localhost:3306, and only waits so long for a reply. it's not getting it, which means the request is either blocked (firewall) or ignored (MySQL is not running and/or is listening on a different port)
If phpMyAdmin came with the MySQL install, then it could be that it was configured to use the appropriately different port
ha i also had that issue now i fix it by changing port number e.g "find.db.13344.hostedfind.com:3306". before it my connection was trying to access the "find.db.13344.hostedfind.com:3307" so it gave me this error
Warning: mysql_connect() [function.mysql-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) .
Maybe your MySQL is not using TCP for localhost. Please try
$host='/tmp/mysql.sock';
or whatever socket it might be using.
I also have noticed this issue linux version of xampp with MySSQL 5.6.12-log running over network. Also, a question asked in MySQL forum (http://forums.mysql.com/read.php?52,294772,294772) resembles this, but not satisfactorily answered.
What I have noticed is, it is probably due to Networking being unstable, or too many mysql connections from other developers in the network connecting to the database server at the same time - and keeping the port number busy for a fraction of time. It is not often related to the configured connection time, nor maximum execution time, nor wrong username/password etc.
Amazingly, the same script, same password, and same network allows the same server run properly on the second attempt - without having to do anything as a fix.
Hence, it should be your momentarily unstable network fluctuation (or busy mysql connections), that goes on and off, and your script attempted to connect to the server when network was down for a very short time.
That is a guessed answer from personal experience related to this error, may not be exact.
But if the error message is persistent, you should really need to do something.
I get this everytime I use mysql_connect() no matter what database I choose:
Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'IP' (111) in filename.php on line 17
A MySQL error has occurred: Can't connect to MySQL server on 'IP' (111)
The exact same file works on my personal website fine. I have tried multiple databases hosted on different servers and it always gives that output.
The database itself is hosted on the same server, but using its full IP in mysql_connect(). Using localhost:port doesn't work either as it says:
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in filename.php on line 17
A MySQL error has occurred: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
But using the IP should work as it has worked calling it via the same file hosted on other servers.
This is the code:
$connect = mysql_connect($db_url,$db_user,$db_pass); // connects
if ($connect == false) exit("A MySQL error has occurred: " . mysql_error());
Now since the file works on other servers i am guessing it is something to do with the server it is on and might need something changed. I don't personally have root access to the server (just my part of the shared host). Is there anything I can do i php, editing the php.ini file or something I should pass on to someone with root access?
Edit: Ok it turns out that the server doesn't have access to outside databases, so thats why the IP didn't work. Thanks for all your answers but we have decided simply to change hosting provider. We need to be able to access an outside database.
This is on a hosting service? Check their documentation, there will be something that tells you where to find mysql. It isn't necessarily localhost.
For example, on startlogic.com, you use: yourdomain.startlogicmysql.com
Can you connect using mysqladmin using the same host, username and password?
mysqladmin -h $db_url -u $db_user -p $db_pass
Replace $db_xxxx with real values.
If that works from the same host as your php script, then sudo to the apache User and try the same test. One of those must be failing.
EDIT: nevermind on sudo part, I noticed that you don't have root access.
Something else to try: Use '127.0.0.1' instead of 'localhost'. I have had issues before where mysql stupidly assumed it could silently change 'localhost:' to '/var/run/mysqld/mysqld.sock'.
Your wording is not very clear, I hope you are not thinking you can connect to the same mysql server from any old web server just because you know the IP address and port number. If the web host is at all competent, they have probably firewalled mysql so it is only accessible through their own web servers.