Yii Framework Forum: Database Connection With Remote Ip - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Database Connection With Remote Ip

#1 User is offline   raviteja mandarapu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 25-March 13

Posted 29 January 2014 - 08:57 AM

Hi Team am unable to connect database throuth ip host its always connecting to the localhost only


here is code:

'class'=>'CDbConnection',
'connectionString' => 'mysql:host=10.10.11.281; port=3306; unix_socket=/opt/lampp/var/mysql/mysql.sock;dbname=' . $_SESSION['dbconnect'],
// 'connectionString' => "mysql:host=localhost;dbname=mydb",
'emulatePrepare' => true,
'username' => 'root',
'password' => 'root',
// 'queryCachingDuration' => 3000,
'enableParamLogging' => true,
'charset' => 'utf8',
),
and am getting error like
CDbConnection failed to open the DB connection: SQLSTATE[HY000] [1130] Host 'RAVITEJA-DESKTO' is not allowed to connect to this MySQL server

Attached File(s)


0

#2 User is offline   satyanarayana 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 33
  • Joined: 30-January 14
  • Location:Hyderabad

Posted 31 January 2014 - 05:57 AM

hi raviteja, first of all you have to configure your remote database for remote access.


you can refer to my blog on this:
satya-nitk.blogspot.in/search/label/DBMS

In may case remote database is on '10.100.39.172'

$hostname='10.100.39.172';
$user='satya';
$password='satya';
$dbname='Amantran';


//syntax of database connection
$con=mysqli_connect($hostname,$user,$password,$dbname)
0

#3 User is offline   JFReyes 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 506
  • Joined: 28-October 09
  • Location:Puerto Rico

Posted 31 January 2014 - 06:56 AM

The Yii way is as follows (taken from the Guide).

Inside config/main.php set up the database connection:
array(
    ......
    'components'=>array(
        ......
        'db'=>array(
            'class'=>'CDbConnection',
            'connectionString'=>'mysql:host=localhost;dbname=testdb',
            'username'=>'root',
            'password'=>'password',
            'emulatePrepare'=>true,  // needed by some MySQL installations
        ),
    ),
)

José
0

#4 User is offline   raviteja mandarapu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 25-March 13

Posted 04 March 2014 - 04:07 AM

View PostJFReyes, on 31 January 2014 - 06:56 AM, said:

The Yii way is as follows (taken from the Guide).

Inside config/main.php set up the database connection:
array(
    ......
    'components'=>array(
        ......
        'db'=>array(
            'class'=>'CDbConnection',
            'connectionString'=>'mysql:host=localhost;dbname=testdb',
            'username'=>'root',
            'password'=>'password',
            'emulatePrepare'=>true,  // needed by some MySQL installations
        ),
    ),
)


0

#5 User is offline   justinthomasonline 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 19-July 12
  • Location:india,kerala,kottayam

Posted 21 August 2014 - 01:27 AM

hi raviteja, the issue CDb connection failed to open the DB connection SQLSTATE[1130] not allowed to connect to this server

This error mainly happening due to bad or unsufficient privileges of phpmyadmin. So you should set correct privileges by changing privileges in localhost/phpmyadmin link.

here you could add a new user with all privileges and set that user and password in yii protected/main.php database settings
or
provide enough privileges to root user

Try it best of luck
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users