Reputation: 4745
I am unable to make a database connection from the App Engine SDK server to my local MySQL which was installed with MAMP. I understand that this is about the MySQL socket file which is in MAMP. How can I let App Engine SDK to listen to the local MySQL? I also want to ensure that my MAMP setup remains intact. Thanks.
Upvotes: 2
Views: 975
Reputation: 6399
I don't know in which situation the error occurred to Nagarjun, but to me happened with the following PHP warning
Warning: mysql_connect(): No such file or directory in /Users/Aerendir/Documents/JooServer/_SandBox/GoogleAppEngine/continuous-wordpress-cms/wordpress/wp-includes/wp-db.php on line 1372
In my situation, i were trying to install WordPress on Google AppEngine following their tutorial.
The problem was the hostname I used: localhost instead of 127.0.0.1
Using 127.0.0.1 as hostname solved the problem.
The solution was found here: Configuring MySQL connection in Google App Engine PHP SDK on Windows 7
Upvotes: 0
Reputation: 23
App engine SDK for php can connect to you local MySql server in your development environment. First make sure you have the latest SDK for PHP version, currently release 1.8.6. Make sure your local MySql server instance is running and listening on port 3306. Add your application in the App Engine SDK Launcher, click on it and select Edit / Application Settings and add in the "Extra Command Line Flags" field the following: --mysql_user=user Where user is the username to connect to your database. Then you have to connect to your DB from your php code, in my case, I'm using PDO. Like this:
try {
$db = new PDO('mysql:unix_socket=/cloudsql/<appname>:my-cloudsql-instance;charset=utf8;dbname=<yourdbname>','<user>','<password>');
syslog(LOG_DEBUG, 'Connected to database.');
} catch (PDOException $e) {
syslog(LOG_ERR, 'Failed to get PDO DB handle: ' . $e->getMessage());
print_r($e->getMessage());
exit;
}
Replace the text with <> tags with your application and MySql server settings.
Upvotes: 1
Reputation: 4096
GAE currently does not allow connection to any remote MySQL server. This is their limit and nothing to do with your setup.
Use their Cloud SQL instead.
Upvotes: 0