I tryed connect to Mlab with php by following code:
$connection = new MongoClient('mongodb://user:pass#ds051605.mlab.com:51605/db');
This code worked correctly in my system but didn't work in host and reterned Error 500 (my host doesn't support from mongo). What is the problem? Is there need to supporting mongo in host?
Additionaly, var_dump($connection) command doesn't show error.
Related
I am new to database. I was trying to connect mysql server with php code. But I don't know why I am getting error for connection.(I tried in windows changing the "localhost:8080" to "localhost" and it worked perfectly.)
MyCode:
<?php
$link = mysqli_connect("localhost:8080","root","","test1");
if($link === false){
die("Error: Could not connect. ".mysqli_connect_error());
}
Refused Warning:
XAMPP Port:
localhost:8080 is for you web server. If your MySQL server runs on default settings, use port 3306. localhost:3306.
$link = mysqli_connect("localhost:3306","root","","test1");
Hope this helps you.
Struggled for half day…… I used XAMPP 8 and connection to MySQL keep refuesed(errno 61). Actually XAMPP install MySQL in VM, so connect it via IP address show in XAMPP. There is no MySQL server on localhost.
Change localhost to XAMPP IP address work for me.
db = pymysql.connect(host="192.168.64.2", port=3306, user="test", password='test', db="test")
Change localhost to 127.0.0.1
I spent a day trying to solve it. mysqli was giving error with localhost.
im trying to use pg_connect to access postgres on another server,,
i did opened the remote access and i can use bash to connect to my postgres server ! and i did host all all client_ip/32 trust in config but when im trying to use pg_connect i get error 500 !
pgsql is also installed and i've checked it with function_exists('pg_connect') and i returns true !
my code is :
$dbconn = pg_connect("host=remote_IP port=5432 dbname=myDB user=postgres") or die("Could not connect");
i've also tried this and get fatal error 500 again
$dbconn = pg_connect("host=remote_IP port=5432 dbname=myDB
user=another_super_user_i_made password=user_password") or die("Could not connect");
what is the problem ?
when you are able to connect to a server from one machine on your network, but get a connection timed out issue from another machine, it usually is due to one of a few things.
1) DNS. The machine you are testing from (the "remote access" as you call it) is able to resolve the DNS name and the webserver running your PHP code is not. You can use actual IP address instead of DNS names to test this.
2) Connectivity. Different machines are connected in different ways in a network. If you are able to get to an IP from the "remote access" machine but the web server is having trouble connecting to it (with "connection timed out"), try connecting directly to that web server (using "remote access" like SSH) and see if you can connect manually from there.
If it's not a network related issue it could be an issue with your default PG timeouts. Try setting them manually with the connect string. Specifically, the "connect_timeout" option, like this:
$d=pg_connect('host=example.com user=pgsql dbname=postgres connect_timeout=5');
There was host blocking issue !
my client hosting was not enabling remote access to DB !
you should check with your hosting that they can trace your problem
I have installed the ssh2 extension and even have it enabled. i have also enabled openssl. Everything seems fine, but when i try to connect to a server i am getting ssh2_connect() unable to connect error. The server i am trying to access is accessible from my machine, i connected to the server via the terminal but when i run the script on my machine it is unable to connect to the server, any ideas what is going wrong here ?
I would appreciate it if you guys could point out som possible reasons that i can check/debug!
My script is like this:
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');
PS: i know there is a libary(phpseclib) that i can use, but i want to use ssh2 extension
Thanks :) !
I'm beginning to migrate a software project from being a desktop application to a web application. Currently I am using a local PHP/MySQL connection that is associated with the desktop it is installed on.
I'm hoping to untangle this and am trying to create a MySQL database through my 1and1 account. I had no trouble creating a database and recorded my account information. I'd like to be able to edit this database using PHP scripts on my system. However, I haven't been able to get a working connection string going. When I run the following PHP script:
$hostname="db*********.db.1and1.com";
$database="db*********";
$username="dbo*********";
$password="*********";
$link = mysql_connect($hostname, $username, $password);
I get the following error when I run the script in my webbrowser:
Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'db*********.db.1and1.com' (11001) in C:\Program Files\xampp\htdocs\Remote_MySQL\rightbid_database_initialize.php on line 74
Connection failed: Unknown MySQL server host 'db*********.db.1and1.com' (11001)
How do I get my local system to recognize the 1and1 server host? Am I structuring my connection string correctly? Is it possible to access a remote server from a locally hosted Windows PHP connection?
Thanks!
I assume what's happening if that 1&1 are blocking any connections coming from outside of their network.
Try connecting using
mysql -h HOST -u USERNAME -p DATABASENAME
Good luck
Make sure the MySQL server on 1and1 will accept connections from remote clients. Not just on localhost, and also make sure port 3306 is open to the server.
I was setting up a local server on my mac using xampp, however i ran into a problem when i needed to set up ssl for my site. I set up the php side to enable ssl that works fine, I can visit 'https://localhost/' fine it loads up the xampp welcome page. Now when it comes to mysql and setting it up to use ssl i cant get it to use ssl. When i go into phpmyadmin and check the variables it says that ssl isn't on and that there is no cipher specified.
I tried going into the config.inc.php and adding the following lines:
$cfg['Servers'][$i]['ssl'] = true;
$cfg['ForceSSL'] = TRUE;
I then restarted apache and mysql servers through xampp and that changed nothing. I then generated my own certificates put them in a folder and added the following to the same config.inc.php file:
$cfg['Servers'][$i]['ca'] = '/Applications/XAMPP/xamppfiles/etc/ssl/ca-cert.pem';
$cfg['Servers'][$i]['cert'] = '/Applications/XAMPP/xamppfiles/etc/ssl/client-cert.pem';
$cfg['Servers'][$i]['key'] = '/Applications/XAMPP/xamppfiles/etc/ssl/client-key.pem';
That also did nothing to change mysql's ssl settings. I was just looking to connect to mysql in php using ssl. My php code looks like this below:
error_reporting(E_ALL);
ini_set("display_errors", "1");
$link = mysqli_init();
mysqli_ssl_set($link,'/Applications/XAMPP/xamppfiles/etc/ssl/server-key.pem','/Applications/XAMPP/xamppfiles/etc/ssl/server-cert.pem','/Applications/XAMPP/xamppfiles/etc/ssl/ca-cert.pem',null, null);
mysqli_real_connect($link,$dbhost, $dbuser, $dbpass, $dbname);
I can't connect with the code above it gives me a ssl error. Is there anyone that can help me set this up so that i can use ssl please?
The MySQL in XAMPP is actually a MardiaDB binary version. That version does not support SSL (TSL).
Try this: How can I change MariaDB to MySQL in XAMPP?