I have problem with connection with my remote database.
Steps, which i did:
1) In GemFile added :
gem 'mysql2'
2) in database.yml:
development:
adapter: mysql2
database: myname
username: myuser
password: mypass
host: myhost.nazwa.pl
port: 3305
3) then in console i typed:
rake db:migrate
Communicat which i got:
Mysql2::Error: Can't connect to MySQL server on 'myhost.nazwa.pl' (4)
I wanted to try if I can connect with this database using small php script:
<?php
$host = 'myhost.nazwa.pl';
$database = 'myname';
$username = 'myuser';
$password = 'mypass';
if ( mysql_connect($host,$username,$password) ) {
echo 'connect to mysql server *** ';
}
if ( mysql_select_db($database) ) {
echo 'open database';
}
if ( !mysql_close() ) {
echo 'cannot close connection';
exit (0);
}
?>
And there is no problem. I can connect, create tables, add data etc.
Could you advise me something? Where can be problem? I will be very thankful. Regards :)
MySQL's default port is 3306 , and you've got 3305 in your configuration for some reason. Unless you're using a custom port, leave the port:
argument out of your configuration file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.