mySQL serveur cannot be connected while apache server works fine. (everything was working fine when I used the previous version of MAMP) Here a message I got when trying to connect
/Applications/MAMP/Library/bin/mysqlcheck: Got error: 2002: Can't connect to local MySQL
server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2) when trying to
connect
By the way when I request an URL in local that does not require any DB connextion its working fine (seems obvious) and when it does require some DB connection I got the following message:
SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (61)
CONFIGURATION:
MAC BOOK OX S 10.8.5
MAMP 3.0.7.3
php 5.6.2
Symfony2
Remove the files ib_logfileN (N being the number) from the MAMP/db/mysql56 folder then restart your MAMP.
If still not working then also delete the ibdataN (N being the number).
Related
Salam and Greetings,
MySQL 8 which installed along with Workbench 8 was configured to work with port # 3307, as the port # 3306 was reserved by MAMP Pro for its own instance of MySQL ver 5.7
I was able to connect my PHP applications that was hosted on an older version of MAMP Pro version 4.1 (i guess) using the below shown connection setup *1
After upgrading to Mamp Pro 4.2, the PHP application failed to access MySQL 8
At this point, MySQL 8 database was still working fine and accessible using Workbench 8,
After several unsuccessful attempts which include re-installation of Workbench 8, MySQL 8 and even MAMP Pro 4.2, I've reset the whole computer and carried out fresh installation of Workbench and MAMP Pro but the issue still persist and the PHP Application still can't access MySQL 8
I've logged this incident to MAMP Pro tow days back but no one yet back to me
I appreciate if someone would suggest a solution to host My PHP on any web-server that allows smooth connection with MySQL 8 (preferable to be MAMP Pro on Windows 10 as I already have a purchased license)
Kindest regards,
*1 PHP connection file:
$host="127.0.0.1";
$port=3307;
$socket="";
$user="root";
$password="password";
$dbname="kaf";
$con = new mysqli($host, $user, $password, $dbname, $port, $socket)
or die ('Could not connect to the database server' . mysqli_connect_error());
//$con->close();
First situation:
I run the php artisan migrate command from a terminal on a laravel project, and it works fine updating the mysql database on
127.0.0.1:3306. This means that the php-mysql connection was fine.
Second situation:
Running the project inside a docker container I was not able to set
the database to 127.0.0.1 since in a docker container that matches
the container itself. I read that docker has a bridge to connect
with the host (in the case of Linux 172.17.0.1). So I changed the mysql
connection settings to 172.17.0.1:3306. And I get:
PDOException
Packets out of order. Expected 0 received 1. Packet size=69
and
PDOException SQLSTATE[HY000] [2006] MySQL server has gone away.
Question:
Why does it work with 127.0.0.1 but from not from inside a container?
I have a problem to connect my online MySQL database from my local system.
I installed XAMPP on my Windows 7 and created a PHP file with this code:
<?php
$db_path = mysqli_connect('printcity24.com', 'printci1_admin', 'xr10s20191', 'printci1_db', '3306');
if(!$db_path) {
echo mysqli_connect_error();
}else{
echo "Connected successfully";
}
?>
Then i created a database on my website : www.printcity24.com
My web host admin configured my host and opened firewall.
When i use XAMPP command line to connect to my database every thing is ok, i can connect to my database remotely with this code :
# mysql -u printci1_admin -p -h printcity24.com
but when i use php code to connect to my database i get this error :
Warning: mysqli_connect(): MySQL server has gone away in D:\Xampp Server\htdocs\st\index.php on line 2
Warning: mysqli_connect(): (HY000/2006): MySQL server has gone away in D:\Xampp Server\htdocs\st\index.php on line 2
MySQL server has gone away
I upload my php code on to other websites and test for connection and everything is "ok" but on my local xampp can't connect.
In this link said i have to use this command :
setsebool -P httpd_can_network_connect=1
but I don't know where to put this code and how to configure my xampp.
Timeout while connecting to MongoDB database with mongo php ext under Ubuntu 12.04 and php 5.6
I'm using
latest Apache 2.4
Ubuntu 12.04
php 5.6 with mongo ext Version 1.6.14
MongoDB v3.4 running in an lxc container
And the problem is when I connect to the mongo database.
I'm using this connection string:
mongodb://myDbUser:passW0rT#0.0.0.0:27020/myDb
(password, database and addr have been changed).
I have verified that php mongo ext is installed, with this code:
echo extension_loaded("mongo") ? "loaded\n" : "not loaded\n"; //prints loaded.
if (class_exists('\MongoClient')) {
echo 'is Mongo Client'."\n";//this is printed
}
else {
echo 'no Mongo Client'."\n";
}
try {
$client = new MongoClient('mongodb://myDbUser:passW0rT#0.0.0.0:27020/myDb', []);
} catch (Exception $ex) {
echo $ex->getMessage();//prints Failed to connect to: 0.0.0.0:27020: Connection timed out
}
What is more strange I can connect to this database using MongoClient and in addition to this I can connect to this database by my local server running on my computer (Win 10).
The problem appears also when I use security.authorization set to enabled and without difference set to disabled – then I use dsn mongodb://0.0.0.0:27020
Unfortunately server's response always gives timeout error when I enter web addr using www (domain which is on the server where mongo database is installed).
It could be one clue that server where mongo is installed is server which runs as container which means that I have to add port number to connect eg. via ssh.
I even changed the server from ngix to apache and problem didn't disappear.
Environment:
Apache 2.2.9
PHP 5.4.37
freetds 0.91
SQL Server 2008
After last night's round of updates applied from Microsoft my mssql_connect stopped working.
tsql -LH x.x.x.x still shows the server and port correctly
tsql -H x.x.x.x -U user connects fine
I get nothing in the apache log files or the freetds log
Here is the code segment that is failing (critical info changed)
error_reporting(E_ALL); ini_set('display_errors',1);
$con = mssql_connect('server', 'user', 'pass');
var_dump($con);
if (!$con) {
if ( function_exists('error_get_last') ) {
var_dump(error_get_last());
}
die('Could not connect to the server!!'.mssql_get_last_message());
}
And here is the result:
Warning: mssql_connect(): Unable to connect to server: server in /home/....../public_html/states/index.php on line 25
bool(false)array(4) { ["type"]=> int(2) ["message"]=> string(55) "mssql_connect(): Unable to connect to server: server"["file"]=> string(63) "/home/....../public_html/states/index.php"["line"]=> int(25) } Could not connect to the server!!
Please help!
I'm unable to post a comment to ask this, but here is my thoughts.
Obviously it's not connecting to the server outside of the command line, so you'll want to double check its configuration (check the server port, specify the port, etc..)
Is this running from a Win or Unix type OS?
It is Linux. I found a work around for the moment. The problem appears to be on the Windows side where, although a tsql -LH command shows the IP and port, it is not actually answering queries on the port. You get connected to the server via TCP and that is it.
Because the SQL server is multi-homed, I added a secondary connection to the web app server that connects to it over the primary IP.
I'll chase down the IP binding and service issue later. Or maybe just convert it all to mariaDB or Postgres.