I am trying to connect to a db remotely using the Yii framework
Is there any specific setting because i can't connect to the db.
'db' => array(
'class' => 'PortalDbConnection',
'connectionString' => 'mysql:host=192.168.0.2;dbname=mydb',
'username' => 'root',
'password' => '',
'tablePrefix' => '',
'emulatePrepare' => true,
'enableParamLogging' => true,
'enableProfiling' => true,
'charset' => 'utf8',
),
Error
2013/10/16 09:14:22 [error] [exception.CDbException] SQLSTATE[HY000]
[2003] Can't connect to MySQL server on 'mysql5.ms.domain.net' (13)
2013/10/16 09:14:22 [info] [application] User: Guest (ID: )
This code is valid for me:
'db'=>array(
'connectionString' => 'mysql:host=192.168.1.96;dbname=dbname',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'enableProfiling'=>true,
'enableParamLogging' => true,
),
Do you have configurated on the DB server the %root access, from remote?
Edited:
For configure remote access:
There's two steps in that process:
a) Grant privileges. As root user execute:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password';
b) bind to all addresses:
The easiest way is to comment out the line in your my.cnf file:
#bind-address = 127.0.0.1
and restart mysql
service mysql restart
@hovanessyan solution: MySQL root access from all hosts
It's a problem of server accessebily, not user access. Check number of port of mysql server (must be 3306, if not - use mysql:host=192.168.0.2;port=<your port>;dbname=mydb
) and try to ping 192.168.0.2
(or maybe can run this nmap -p 3306 -sT 192.168.0.2
, it from here) from the where yii placed