Yii Framework Forum: Rbac in shell generates error message - Yii Framework Forum

Jump to content

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

Rbac in shell generates error message

#1 User is offline   malle 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 01-June 11

Posted 03 June 2011 - 04:16 AM

Hi,

Following the book's instructions in Chapter 8, I was able to open the Yii interactive tool and see Rbac in the list of available commands, but when I ran it, i got this error message, which I don't understand and don't know how to fix :( and I didn't see this topic anywhere on the forum. I'm using MAMP on a Mac (this is my mysql path
/Applications/MAMP/Library/bin/mysql 
) . Something about database problem but I haven't had any trouble connecting to mysql up to this point.

Anyone have an idea?
USAGE
  rbac

DESCRIPTION
  This command generates an initial RBAC authorization hierarchy.

>> rbac

Warning: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /Applications/MAMP/htdocs/framework/db/CDbConnection.php on line 389
exception 'CDbException' with message 'CDbConnection failed to open the DB connection: SQLSTATE[HY000] [2002] No such file or directory' in /Applications/MAMP/htdocs/framework/db/CDbConnection.php:348
Stack trace:
#0 /Applications/MAMP/htdocs/framework/db/CDbConnection.php(297): CDbConnection->open()
#1 /Applications/MAMP/htdocs/framework/db/CDbConnection.php(275): CDbConnection->setActive(true)
#2 /Applications/MAMP/htdocs/framework/base/CModule.php(372): CDbConnection->init()
#3 /Applications/MAMP/htdocs/framework/web/auth/CDbAuthManager.php(540): CModule->getComponent('db')
#4 /Applications/MAMP/htdocs/framework/web/auth/CDbAuthManager.php(58): CDbAuthManager->getDbConnection()
#5 /Applications/MAMP/htdocs/framework/base/CModule.php(372): CDbAuthManager->init()
#6 /Applications/MAMP/htdocs/framework/base/CModule.php(86): CModule->getComponent('authManager')
#7 /Applications/MAMP/htdocs/demo/protected/commands/shell/RbacCommand.php(27): CModule->__get('authManager')
#8 /Applications/MAMP/htdocs/framework/cli/commands/ShellCommand.php(147): RbacCommand->run(Array)
#9 /Applications/MAMP/htdocs/framework/cli/commands/ShellCommand.php(99): ShellCommand->runShell()
#10 /Applications/MAMP/htdocs/framework/console/CConsoleCommandRunner.php(63): ShellCommand->run(Array)
#11 /Applications/MAMP/htdocs/framework/console/CConsoleApplication.php(88): CConsoleCommandRunner->run(Array)
#12 /Applications/MAMP/htdocs/framework/base/CApplication.php(155): CConsoleApplication->processRequest()
#13 /Applications/MAMP/htdocs/framework/yiic.php(33): CApplication->run()
#14 /Applications/MAMP/htdocs/demo/protected/yiic.php(7): require_once('/Applications/M...')
#15 /Applications/MAMP/htdocs/demo/protected/yiic(4): require_once('/Applications/M...')
#16 {main}

0

#2 User is offline   georgebuckingham 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 25-May 11
  • Location:London, UK

Posted 04 June 2011 - 06:32 AM

Can you try running
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
from "Terminal" (found in ~/Applications/Utilities), and then trying again? You will need to type in your password.

If any errors appear, please post them here.
[url="http://georgebuckingham.co.uk"][/url]
0

#3 User is offline   malle 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 01-June 11

Posted 04 June 2011 - 08:37 AM

when I ran the statement you suggested in my terminal, it said


ln: /tmp/mysql.sock: File exists


I then started the Yii interactive tool and ran the same Rbac command, and got the same error message as in my OP.
0

#4 User is offline   georgebuckingham 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 25-May 11
  • Location:London, UK

Posted 04 June 2011 - 08:39 AM

Ok, how about if you do

sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock


If you get an error saying /var/mysql doesn't exist, then run

sudo mkdir /var/mysql


and then the code above again
[url="http://georgebuckingham.co.uk"][/url]
0

#5 User is offline   malle 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 01-June 11

Posted 04 June 2011 - 08:53 AM

I got this from running the statement in your last post


ln: /var/mysql/mysql.sock: File exists


and then when I ran Rbac in Yii interactive tool, I got same error message as in OP
0

#6 User is offline   georgebuckingham 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 25-May 11
  • Location:London, UK

Posted 04 June 2011 - 09:03 AM

Hmm, one more thing.

In your /protected/config/main.php file, where you have your 'db' settings array, try adding this to the end of the 'connectionString' property:

unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock


I'm not familiar with MAMP, so most of what I'm advising is coming from this thread:
http://www.yiiframew...532

It's also been suggested that changing 'localhost' to '127.0.0.1' in you 'connectionString' may solve the problem.
[url="http://georgebuckingham.co.uk"][/url]
0

#7 User is offline   malle 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 01-June 11

Posted 05 June 2011 - 02:54 AM

 georgebuckingham, on 04 June 2011 - 09:03 AM, said:

Hmm, one more thing.

In your /protected/config/main.php file, where you have your 'db' settings array, try adding this to the end of the 'connectionString' property:

unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock


I'm not familiar with MAMP, so most of what I'm advising is coming from this thread:
http://www.yiiframew...532

It's also been suggested that changing 'localhost' to '127.0.0.1' in you 'connectionString' may solve the problem.


There were a number of solutions posted on that site, but I just tried changing localhost to '127.0.0.1' and it worked. Thanks
0

#8 User is offline   flashmcintosh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 01-March 12

Posted 11 March 2012 - 12:50 PM

If your using MAMP, then you might need to add he port number to the connection string.

eg

'connectionString' => 'mysql:host=localhost;port=8889;dbname=testdrive',
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