This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » legacy support » symfony 1.2 » strange doctrine PDO error
strange doctrine PDO error [message #65817] Sun, 23 November 2008 21:54 Go to next message
dimitris  is currently offline dimitris
Messages: 26
Registered: July 2008
Junior Member
Hello,

I just thought I would give symfony 1.2 a try, I was using 1.1 with Propel 1.2. So I enabled Doctrine in a new project I created. I changed the databases.yml file but when I try to connect to the database for example doing doctrine:build-schema, I get

PDO Connection Error: SQLSTATE[28000] [1045]: Access denied for user 'username'@'daringedventures.com' (using password: NO)

Although the username is the correct one, I have no idea where this 'daringedventures.com' comes from (first time I see this and 100% sure I haven't typed something like this anywhere in my code) and I don't know if it's a symfony problem or a server problem. On the one hand I can connect with a database locally on my server with sf 1.2, but on the other hand I am able to correctly connect to the same database on the remote server when using sf 1.1 with Propel 1.2. I also have the same problem when I enable the Propel plugin instead of Doctrine.

Any ideas?

[Updated on: Sun, 23 November 2008 22:08]

Re: strange doctrine PDO error [message #65850 is a reply to message #65817 ] Mon, 24 November 2008 12:17 Go to previous messageGo to next message
matze123  is currently offline matze123
Messages: 19
Registered: April 2007
Junior Member
this is my yml
all:
  doctrine:
    class:    sfDoctrineDatabase
    param:
      dsn:        mysql:dbname=pmrtimedoctrine12;host=localhost
      username:           ....
      password:           .....
      port:               3306
      encoding:           utf8     # Default charset for table creation
      persistent:         true      # Use persistent connections      

Re: strange doctrine PDO error [message #65854 is a reply to message #65850 ] Mon, 24 November 2008 13:02 Go to previous messageGo to next message
dimitris  is currently offline dimitris
Messages: 26
Registered: July 2008
Junior Member
i don't think that there's anything wrong with my yaml file but here it is

dev:
  doctrine:
    param:
      classname:  DebugPDO

test:
  doctrine:
    param:
      classname:  DebugPDO

all:
  doctrine:
    class:        sfDoctrineDatabase
    param:
      classname:  DoctrinePDO
      dsn:        mysql:dbname=database_name;host=mysql.mydomain.com
      username:   username
      password:   password
      encoding:   utf8
      persistent: true
      pooling:    true


I cannot really understand what the problem is since as I said I can connect to a different database locally and I also tried today to connect to another database on the same server within exactly the same project, so it's doesn't look to be like a symfony problem BUT on the other hand the username and password are set up correctly in the mysql server and I can connect to the database either with symfony 1.1 or mysql or phpMyAdmin or whatever. It's really weird!!
Re: strange doctrine PDO error [message #65855 is a reply to message #65817 ] Mon, 24 November 2008 13:05 Go to previous messageGo to next message
matze123  is currently offline matze123
Messages: 19
Registered: April 2007
Junior Member
mmh

you can test it without all classname lines
and without pooling line
Re: strange doctrine PDO error [message #65879 is a reply to message #65855 ] Mon, 24 November 2008 17:33 Go to previous messageGo to next message
dimitris  is currently offline dimitris
Messages: 26
Registered: July 2008
Junior Member
thanks, but it doesn't help...
Re: strange doctrine PDO error [message #65898 is a reply to message #65817 ] Tue, 25 November 2008 00:26 Go to previous messageGo to next message
GaryFx
Messages: 377
Registered: May 2008
Location: Masschusetts
Faithful Member
Try:

dsn://username:password@hostname/databasename
Re: strange doctrine PDO error [message #65900 is a reply to message #65817 ] Tue, 25 November 2008 02:53 Go to previous messageGo to next message
jphilip  is currently offline jphilip
Messages: 11
Registered: October 2008
Junior Member
Can you connect directly with PDO?
If not the problem is not with Symfony or Doctrine.

<?php
try {
    $dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
    foreach($dbh->query('SELECT * from FOO') as $row) {
        print_r($row);
    }
    $dbh = null;
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";
    die();
}
?>
Re: strange doctrine PDO error [message #65997 is a reply to message #65900 ] Tue, 25 November 2008 22:34 Go to previous messageGo to next message
dimitris  is currently offline dimitris
Messages: 26
Registered: July 2008
Junior Member
Thanks GaryFX, I used

dsn: mysql://username:password@hostname/databasename

and it seems to work with doctrine so far. But with Propel i get:

[propel-schema-reverse] There was an error building XML from metadata: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
                                                   
Some problems occurred when executing the task:  
Read the logs to fix them


I checked at the log folder but there's nothing there.
I have also asked my mysql administrator about it and he said that it doesn't have anything to do with the server and to ask the symfony developers.

jphilip, I tried your code but I get the following:


Invalid argument supplied for foreach at .../test.php on line 4


I haven't used PDO in the past but you're right i'll try to find out this way where is the problem, since even if it works with Doctrine I'm much more familiar with Propel.
Re: strange doctrine PDO error [message #65999 is a reply to message #65997 ] Tue, 25 November 2008 23:32 Go to previous messageGo to next message
GaryFx
Messages: 377
Registered: May 2008
Location: Masschusetts
Faithful Member
Doctrine and Propel use different formats, in spite of both using PDO. Or at least, I currently have both working with different formats in my respective databases.yml files.

For Propel 1.3, use the .yml file you posted previously, but with all the Doctrine occurrences changed to Propel.
Re: strange doctrine PDO error [message #66004 is a reply to message #65999 ] Wed, 26 November 2008 01:43 Go to previous messageGo to next message
dimitris  is currently offline dimitris
Messages: 26
Registered: July 2008
Junior Member
Thanks. I do replace all Doctrine with Propel. And I also tried to use the same dsn format in propel.ini

propel.database.url = mysql://username:password@hostname/database


instead of

propel.database.url        = mysql:dbname=database;host=hostname
propel.database.user       = username
propel.database.password   = password


but i still get the same error.
Re: strange doctrine PDO error [message #70717 is a reply to message #66004 ] Mon, 26 January 2009 11:32 Go to previous messageGo to next message
padma  is currently offline padma
Messages: 21
Registered: January 2009
Location: Nepal-Kathmandu
Junior Member

Hi,

Have you solved the issue?

I am also facing the same problem.I didnot figureout what exactly the problem.

I would really appreciate any advice you care to give.

Regards,


Padma G.C.
Re: strange doctrine PDO error [message #70783 is a reply to message #70717 ] Mon, 26 January 2009 23:54 Go to previous messageGo to next message
dimitris  is currently offline dimitris
Messages: 26
Registered: July 2008
Junior Member
not really. do you have this problem only with sf 1.2 or with 1.1? propel or doctrine?

are your referring to the problem as described in the first post or later? i think that this is incorrect reverse dns resolution, and it is not something to worry, it is not the cause.

the problem of SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' is probably, in my case, caused by the fact that i'm on a linux-based share host (jailed user) that i have more restrictions and no access to the system files. it is still strange and cannot understand why it was working with doctrine and not with propel, but it probably has to do with the server. i could connect at last with pdo too. i sometimes encountered this problem outside symfony in executing sql statements, although it was rare. but that's the strangest thing, that sometimes it works sometimes not, with some databases yes with others no! anyway, hope this helps, let me know if you find out something more on this
Re: strange doctrine PDO error [message #70793 is a reply to message #70783 ] Tue, 27 January 2009 04:21 Go to previous messageGo to next message
padma  is currently offline padma
Messages: 21
Registered: January 2009
Location: Nepal-Kathmandu
Junior Member

I has also been working a linux server.
No,I have a problem with sandbox neither with sf 1.2 nor with 1.1.Yes,its a propel.
 i think that this is incorrect reverse dns resolution, and it is not something to worry, it is not the cause.


My database.yml

dev:
  propel:
    param:
      classname: DebugPDO
test:
  propel:
    param:
      classname: DebugPDO
all:
  propel:
    class: sfPropelDatabase
    param:
      classname: PropelPDO
      dsn: 'mysql:host=localhost;dbname=db_jobeet'
      username: root
      password: null
      encoding: utf8
      persistent: true
      pooling: true


Dont know ,was the problem created due to symfony or other.
i am newbie in symfony facing lots of problem.

Actually my error message:

Some problems occurred when executing the task:                                                                                                  
    build-propel.xml:275:1:  [wrapped: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)]  
    Read the logs to fix them   


Would really appreciate your help.


Regards

[Updated on: Tue, 27 January 2009 04:22]


Padma G.C.
Re: strange doctrine PDO error [message #70830 is a reply to message #70793 ] Tue, 27 January 2009 15:56 Go to previous messageGo to next message
dimitris  is currently offline dimitris
Messages: 26
Registered: July 2008
Junior Member
have you tried the following

dsn: mysql://username:password@hostname/database

without the username and password lines?

do the same in the propel.ini file, see previous posts
Re: strange doctrine PDO error [message #75311 is a reply to message #65817 ] Fri, 20 March 2009 17:30 Go to previous messageGo to next message
facetasm  is currently offline facetasm
Messages: 10
Registered: September 2007
Location: Cologne
Junior Member
I had the "PDO Connection Error" on a Mac - Leopard (OS X 10.5):

While exporting model class 'JobeetAffiliate' to SQL: PDO Connection Error: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Solution after some googlin:

dsn: 'mysql:host=localhost;dbname=jobeet;unix_socket=/var/mysql/mysql.sock'

this might be helpful for macos 10.5. users, looking for /tmp/mysql.sock that is actually at /var/mysql/mysql.sock
( http://dev.mysql.com/doc/refman/5.1/en/mac-os-x-installation .html)
Re: strange doctrine PDO error [message #84966 is a reply to message #65817 ] Tue, 08 September 2009 08:04 Go to previous messageGo to next message
ravi_kachh  is currently offline ravi_kachh
Messages: 30
Registered: July 2009
Location: India
Member
Generally this kind of errors occure if we provide wrong username and password while creating dayabase yml file.

Please chk your username and password given.

Re: strange doctrine PDO error [message #85786 is a reply to message #84966 ] Sat, 26 September 2009 03:45 Go to previous messageGo to next message
brak  is currently offline brak
Messages: 8
Registered: September 2009
Junior Member
The solution did work for me too.. I'm on Mac OS 10.6 (Snow Leopard) with MAMP.. I had to add the following:

dsn: 'mysql:host=localhost;dbname=jobeet;unix_socket=/Application s/MAMP/tmp/mysql/mysql.sock'

bascially finding where the mysql.sock is and putting that in..

Thanks for the solution.

Re: strange doctrine PDO error [message #86475 is a reply to message #75311 ] Sun, 11 October 2009 20:12 Go to previous messageGo to next message
kindrosker  is currently offline kindrosker
Messages: 44
Registered: July 2008
Location: Ukraine
Member
facetasm wrote on Fri, 20 March 2009 17:30

I had the "PDO Connection Error" on a Mac - Leopard (OS X 10.5):

While exporting model class 'JobeetAffiliate' to SQL: PDO Connection Error: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Solution after some googlin:

dsn: 'mysql:host=localhost;dbname=jobeet;unix_socket=/var/mysql/mysql.sock'

this might be helpful for macos 10.5. users, looking for /tmp/mysql.sock that is actually at /var/mysql/mysql.sock
( http://dev.mysql.com/doc/refman/5.1/en/mac-os-x-installation .html)


I want to say thank you.
I'm using ubuntu 9.04 http://www.ubuntu.com and xampp http://www.apachefriends.org/en/xampp-linux.html#372
and had the same problem
I save a lot of time found your post, thank you!Smile


My symfony projects: project management tool, web buttons maker
Re: strange doctrine PDO error [message #86741 is a reply to message #86475 ] Thu, 15 October 2009 07:08 Go to previous messageGo to next message
rmzamora  is currently offline rmzamora
Messages: 5
Registered: March 2008
Location: Philippines
Junior Member

for ubuntu users follow this link http://ubuntuforums.org/showthread.php?t=597129http://ubuntuforums.org/showthread.php?t=597129
Re: strange doctrine PDO error [message #89738 is a reply to message #65817 ] Thu, 10 December 2009 14:46 Go to previous messageGo to next message
Isuka  is currently offline Isuka
Messages: 3
Registered: February 2007
Location: Montpellier, France
Junior Member

I got the same error with symfony 1.4.
I tried both syntax :
dsn:      'mysql:dbname=db2128602;host=mysql03;unix_socket=/var/lib/mysql/mysql.sock;'
      username: username
      password: password

and
dsn:      mysql://username:password@mysql03/db2128602

None of them works for me.

The host in my yaml file is mysql03 and I got this error :
PDO Connection Error: SQLSTATE[28000] [1045] Access denied for user 'user21286'@'web31' (using password: YES)


Any idea ?
Re: strange doctrine PDO error [message #96804 is a reply to message #65817 ] Mon, 05 April 2010 15:24 Go to previous messageGo to next message
Ehsan  is currently offline Ehsan
Messages: 19
Registered: September 2009
Location: IR
Junior Member

Solution was :
dsn: 'mysql:host=localhost;dbname=jobeet;unix_socket=/opt/lampp/var/mysql/mysql.sock'
Re: strange doctrine PDO error [message #97815 is a reply to message #65817 ] Wed, 21 April 2010 22:39 Go to previous message
thinkingserious  is currently offline thinkingserious
Messages: 1
Registered: April 2010
Junior Member
I fixed the problem in Snow Leopard with this command:
ln -s /Applications/mampstack-1.1-2/mysql/tmp/mysql.sock /tmp/mysql.sock

[Updated on: Wed, 21 April 2010 22:40]


http://www.thinkingserious.com
Previous Topic:Troubleshooting view loading extremely slowly.
Next Topic:Dynamic folder in sfWidgetFormInputFileEditable
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software