Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

localhost vs 127.0.0.1, former works only in page, latter only in CLI. #1693

Closed
reecefowell opened this issue Jul 14, 2011 · 8 comments
Closed

Comments

@reecefowell
Copy link
Contributor

When using the parameters.ini file, setting the database_host to 127.0.0.1:8889, the page will not load, and gives an error of:
"SQLSTATE[HY000] [2005] Unknown MySQL server host '127.0.0.1:8889' (1)", however, it does work with the CLI when doing things such as 'php app/console doctrine:schema:update --force' for example.

If you do the inverse, and set the databse_host to 'localhost', then the issue is reversed, the project page starts working again with no errors but the CLI stops working with the database.

I am using the commonly used MAMP (http://www.mamp.info/en/index.html) on Mac OS X 10.6.8. Though i doubt that bares too much relevance.

so in summary:
database_host="localhost" <-- CLI Does Not Work, Project Works.
database_host="127.0.0.1:8889" <-- CLI Works, Project Does Not Work.

Your concerns are appreciated.

Thanks, Reece.

@robo47
Copy link

robo47 commented Jul 14, 2011

what happens with localhost:8889 ?

@reecefowell
Copy link
Contributor Author

with localhost:8889 CLI works, but the project still does not work.

@henrikbjorn
Copy link
Contributor

This is not a Symfony issue but a local or Doctrine one.

@robo47
Copy link

robo47 commented Jul 14, 2011

@reecefowell
Copy link
Contributor Author

@robo47 thanks, it seems like its what i need, except symfony 2 won't take the same config options that symfony 1 used to take; less i be mistaken.

If i put in any of the following; it thinks the whole thing is just the hostname and ignores the options:
database_host="mysql:host=localhost"
database_host="-h=127.0.0.1; --port=8889;"
database_host="-host:127.0.0.1; --port=8889;"

What would be the proper format? I am still playing with the values but nothing is working thus far.

@lenar
Copy link
Contributor

lenar commented Jul 14, 2011

Take a look at symfony/symfony-standard#151.

@fabpot
Copy link
Member

fabpot commented Jul 15, 2011

The proper way is to set a port setting as shown by @lenar.

@fabpot fabpot closed this as completed Jul 15, 2011
@reecefowell
Copy link
Contributor Author

For anyone else using MAMP, found the solution to be, upgrade to MAMP 2.0, go to preferences, then go to 'ports' then click "Set to default Apache and MySQL ports" button. Wait for MySQL and Apache to restart. Once it has restarted set your symfony apps preferences.ini host to 127.0.0.1, no need to specify a port. It should work then no both the browser and your CLI.

Just incase you changed any configs, it should set default ports of 80 for Apache, (i had 8888 which is wrong.), and mySQL should be 3306 (i had 8889 which is wrong).

Sorry for any inconvenience this caused anyone trying to diagnose issue, and i am very grateful for your help.

fabpot added a commit to symfony/symfony-standard that referenced this issue Jul 18, 2011
Commits
-------

ac65cfb Add a way to easily specify database connection port

Discussion
----------

Add a way to easily specify database connection port

---------------------------------------------------------------------------

by lenar at 2011/07/14 14:43:12 -0700

Related to symfony/symfony#1693.
mbence pushed a commit to mbence/csaladsegito that referenced this issue Feb 3, 2014
Commits
-------

ac65cfb Add a way to easily specify database connection port

Discussion
----------

Add a way to easily specify database connection port

---------------------------------------------------------------------------

by lenar at 2011/07/14 14:43:12 -0700

Related to symfony/symfony#1693.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants