I am unable to connect my script to database on my server (cPanel/WHM)
But the script is working on my localhost WAMP
The database is attached correctly other script is working but only this script is not woorkign
Screen SHot
If the database host and host of your application are different: add the ip of your application host to the whitelist (Remote MySQL icon in cPanel)
Check your credentials
Check the privileges of the user
Related
I am trying to access to the database of my live website from localhost. My website is working on cpanel hosting.
I created database and added user to that database but can not connect to this database from my localhost .
this is the code of database information
<?php
$conf['dbuser']='admin_root';
$conf['dbpass']='rootroot!##$';
$conf['dbname']='bsaiiian_os';
$conf['dbhost']='example.com';
$conf["title"]='DEMO';
?>
I think the problem is from $conf['dbhost'] variable where I'm putting the url of my site and not sure if that is right.
When I'm uploading my script to the hosting and put
$conf['dbhost']='localhost';
the connection is established .
this is error message:
Connection failed: No connection could be made because the target machine actively refused it.
Due to security reasons cPanel's MySQL requires that you allow your IP in order to have access.
This is done through:
cPanel -> Remote MySQL Connection
You need to navigate there and allow your local computer's IP in order to make the connection.
Side Note: This stands true for all IPs, even the server's one that your account is hosted on. You will see your cPanel account's IP already present in there - this is to allow access to MySQL for any files from your cPanel account
I have a database that I want to transfer to my remote server from localhost. The file being too big, I wrote the code to copy the table. But the problem the connection is not successful. My code looks like this.
$server_conn=mysqli_connect($db_host,$db_user,$db_pass,$db_name);
if (!$server_conn) {
die("Server Connection Fail: " . mysqli_connect_error());
}
Where $db_host is the ip address of my server.
When I load the script the error I get is
Server Connection Fail: Access denied for user db_user#'117.202.126.83' (using password: YES)
The credentials are correct, the host is correct, and the weirdest part is 117.202.126.83 is my IP address.
I don't know how is it ignoring the host and taking my connection IP address for host. Even when I give the db_host as the IP address of my remote server.
Also, I am running the script using Easy PHP 14.1 running APACHE 2.4.7,MYSQL 5.6.15 and PHP 5.4.24.
What am I missing?
UPDATE: I am not sure if I was stupid or if the hostgator instructions were.
They ask us to add the cpanel username followed by an underscore before the database name and database username.
In the cpanel, the cpanel username is prefixed by force to all user and db names. So in my case, I had the variables as cpanelUsername_cpanelUsername_databaseName and so on.
Thank you guys for your replies
Go to the cpanel where your phpMyAdmin has the access.
Click on Remote MySQL
Add the access host (Your local IP which is running the script)
Then you can get access to remote mysql server.
You can then test the connection using MySQL Workbench ()
are you sure you use the proper external database hostname/ip?
I'm trying to connect to a remote database on a server which is accessed through cPanel.
I created a user name and associated it with a database. I'm using:
I'm confused on the host name to use. I tried using the Main Domain name in the left menu panel in cPanel with the port number 3306 but it wouldn't work. I used the shared IP as well with the port number that that wouldn't work as well. I have added my local machine IP to the remote databases page in the cPanel as was told in a post but finally I'm not able to connect to the database.
On echoing the mysql_error(), I get:
Can't connect to MySQL server on 'host_name' (4)
Any help would be great!
your hosting site will specify which name should be used for the host
in hostinghood.com they says that to use localhost itself as host name
so check what your hosting site says about it
I have an online reservation booking system (php script) that uses a mySQL database. Part of the script is a back end admin panel for offline reservations.
Is it possible to run a service like XAMPP using local host to access the remote database.
You can connect to remote database by having remote host, db username, db password.
Host name = (use the db server IP address)
Database name = (cpanelUsername_databaseName)
Database username = (cpanelUsername_databaseUsername)
Database password = (*)
MySQL Connection Port = 3306 (check your)
If you are using cPanel then you need to allow your local IP for DB access first.
Login to cpanel, on the main menu of CPanel,
Jump down to "Databases" and select "Remote MySQL"
Now add your IP address, or IP range with a wildcard such as 12.34.%
Good Luck
Yes. You need login credentials for the remote database as well as it's port and server address (hostname or IP), as you'd expect. The remote host also needs to have permissions granted for that particular user to access the database remotely, which users will not have by default.
Yes it is. Just the way you connect your local database, you can connect to a remote database with valid credentials. Then only thing changes is the hostname parameter.
for an example if your database is hosted on dreamhost, they have hostnames like..mysql.yourdomain.com. Create a database on your remote server and connect to it as
<?php
mysql_connect('mysql.yourdomain.com','username','password');
website A: hosted on some free web host.
website B: my server
I want to connect from website B-(client) to mysql server of website A-(my server).
I've granted remote permission on mysql user with %.
But connection doesn't work. I've tried to run php script (mysql_connect) on different free web hosts.
000webhost.com : Can't connect to MySQL server on 'My SERVER IP' (4)
biz.nf : Lost connection to MySQL server during query
same script different mysql errors.
this php script run smoothly on my online SERVER, and also on localhost setup (connecting remotely to SERVER).
Is something else I've to configure on my SERVER?
I know that free web hosts doesn't allow remote mysql connection but in my situation I'm trying to connect with my own mysql server.
Does "remote mysql access" means both in and out connetion?
I've search a lot, something to do with ip-binding or port? I dont know where is actual problem?
Kindly help me out.
Tell mysql that it should listen on a fixed IP address, not 127.0.0.1 or localhost.
open file /etc/mysql/my.cnf (or /etc/my.cnf):
before
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
after
# INSERT YOUR IP Address here
bind-address = 192.168.45.1
#bind-address=127.0.0.1
Then restart your mysql server. HTH
Does your remote website's firewall allow external connections to the MySQL Port 3306?
Find this out to make sure you aren't spinning your tires