Search code examples
pdosymfony-1.4sfguardroot

How do I add sfguard superuser via command line? Currently I just get a PDO connection error


Sorry if this is base, I don't know much about Symfony.

I'm trying to set up a fresh, live database to populate. I have copied the schema from our test server, but dont want the whole test db. This means I have no admin user to work in the backend.

What I want to do is add a super user via the command line. I found this: How to add users to sfguard

But I get the following error:

Unable to open PDO connection [wrapped: invalid data source name]

Also, I don't think the user created here would be a superadmin, no?

If anyone can explain the error or how to add a superuser it would make my life a tonne better and mean I can get some actual stuff done (instead of banging my head against the keyb). Thanks in advance!


Solution

  • The error message is about PDO can not connect to your database. You should edit config/databases.yml and fill in your connection information correctly like:

    all:
      doctrine:
        class: sfDoctrineDatabase
        param:
          dsn:      mysql:host=localhost;dbname=your_database_name
          username: your_username
          password: your_password #(or null if no password)
    

    For more information see databases.yml reference

    To create a new user use php symfony guard:create-user [email protected] username passwod and than make this user super admin php symfony guard:promote username