简体   繁体   English

无法连接到Google云端SQL。 使用PHP Google SDK

[英]Could not connect to Google cloud SQL. Using PHP Google SDK

I did read this tutorial https://developers.google.com/appengine/docs/php/cloud-sql/ I had created a Instance with name schoolnbd and my project id is myapplication-2013 After reading the tutorial I tried the code below 我读过这个教程https://developers.google.com/appengine/docs/php/cloud-sql/我创建了一个名为schoolnbd的实例,我的项目ID是myapplication-2013阅读完本教程后我尝试了下面的代码

<?php
$dhost=":/cloudsql/myapplication-2013:schoolnbd";
$duser="root";
$dpassword="xxxyyy";
$database="schoolnbd";
$connection=mysql_connect($dhost, $duser, $dpassword) or die("Could not Connect to SQL Server Suleman");
$db=mysql_select_db($database, $connection) or die(" Check the Database Name from Config.php , wrong database entered ");
?>

But it is showing “Could not Connect to SQL Server Suleman”. 但它显示“无法连接到SQL Server Suleman”。 I had created one user by name suleman and made several changes , but still it is not connecting to SQL server, i am seeing same message. 我创建了一个名为suleman用户,并进行了一些更改,但仍然没有连接到SQL服务器,我看到相同的消息。 I had tried doing many changes such as 我曾尝试做过很多改动,比如

try 1 试试1

$dhost=":/cloudsql/myapplication-2013:schoolnbd";
$duser="suleman";

try 2 尝试2

$dhost="localhost";
$duser="root";

try 3 尝试3

$dhost=":/myapplication-2013:schoolnbd";
$duser="root";

try 4 尝试4

$dhost=":/cloudsql/myapplication-2013:myapplication-2013:schoolnbd";
$duser="root";

try 5 尝试5

$dhost=":/cloudsql/myapplication-2013:myapplication-2013:schoolnbd";
$duser="suleman";

Error from the error log is it is Showing mysql_connect(): Access denied for user 'root'@'localhost' (using password: YES) in /base/data/home/apps/s~myapplication-2013/1.371632998623546850/test.php on line 6 错误日志中的错误it is Showing mysql_connect(): Access denied for user 'root'@'localhost' (using password: YES) in /base/data/home/apps/s~myapplication-2013/1.371632998623546850/test.php on line 6

when I am using 当我使用时

$dhost=":/cloudsql/myapplication-2013:schoolnbd";
$duser="root";

i also faced the same problem, try without using password, it like this it will most probably work 我也面临同样的问题,尝试不使用密码,这样它很可能会工作

$dhost=":/cloudsql/myapplication-2013:schoolnbd";
$duser="root";
$dpassword="";

but keep in mind , if you had set your root password then you should update root password, by typing this in console. 但请记住,如果您设置了root密码,那么您应该在控制台中输入root密码来更新root密码。

SET PASSWORD FOR 'root' = PASSWORD('');

如果使用root用户从AppEngine进行连接,则不应提供密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM