[英]mysql ERROR 2003 [HY000] - When i'm trying to connect to remote mysql
I have mysql database in shared hosting that defined with %
in "remote MySQL" in a Cpanel我在共享主机中有一个 mysql 数据库,它在Cpanel 的“远程 MySQL”中用
%
定义
And I type within CMD:我在 CMD 中输入:
C:\xampp\mysql\bin>mysql -u SiteName_username -p pass_of_mysql -h srv3.linuxisrael.co.il
I press ENTER我按回车
Enter password :
I press ENTER我按回车
PS - It's right to press here ENTER ?
PS - 在这里按 ENTER 是正确的吗?
I do not have a password in MySQL installed on my computer
我的计算机上没有安装 MySQL 的密码
And i get :我得到:
mysql error 2003 (hy000) Can't connect to MySQl server on 'srv3.linuxisrael.co.il' (10060 "Unknown error")
And in Laravel 5.1 i get this error:在 Laravel 5.1 中,我收到此错误:
PDOException in Connector.php line 55:
Connector.php 第 55 行中的PDOException :
SQLSTATE[HY000] [2002] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
SQLSTATE[HY000] [2002] 连接尝试失败,因为连接方在一段时间后没有正确响应,或者由于连接的主机没有响应而建立的连接失败。
it's configured so :它是这样配置的:
env file: .env 文件:
APP_ENV=local
APP_DEBUG=true
APP_KEY= ...........
DB_HOST=srv3.linuxisrael.co.il
DB_DATABASE= name_of_my_database
DB_USERNAME=name_of_database_username
DB_PASSWORD=password_of_the_username
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
Routes.php :路线.php :
use App\User;
Route::get('/', function(){
User::create(['first_name' => 'moti']);
return view('welcome');
});
How can I connect to MySQL?如何连接到 MySQL?
I want to connect through Laravel But I see that it does not work for me even when I try via the CMD我想通过 Laravel 连接但我发现即使我通过CMD尝试它也不适合我
What's the solution?解决办法是什么?
thank you very much !非常感谢 !
I have checked using following command through CMD:我已经通过 CMD 使用以下命令进行了检查:
telnet srv3.linuxisrael.co.il 3306
It is not able to connect through port 3306. So it seems there is some issue with the server side and port 3306 is not opened to the world.无法通过3306端口连接。所以服务器端似乎有问题,3306端口没有对外开放。
You can check the mysql connection using following simple PHP code snippet.您可以使用以下简单的 PHP 代码片段检查 mysql 连接。
$conn = mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error());
mysql_select_db($dbname, $conn) or die(mysql_error());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.