CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • amp config issue "Connection failed" when entering mysql_dsn
Pages: [1]

Author Topic: amp config issue "Connection failed" when entering mysql_dsn  (Read 469 times)

lolas

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
    • Freeform Solutions
  • CiviCRM version: Several
  • CMS version: Drupal
  • MySQL version: 5.1+
  • PHP version: Several
amp config issue "Connection failed" when entering mysql_dsn
February 06, 2015, 06:32:34 am
The subject says it all. I have double and triple checked the credentials using the mysql client but I am getting the error message "Connection failed" in ./amp config when entering the value for mysql_dsn at the prompt. I am entering in the form mysql://root:passwordforroot@localhost:3306.
Any ideas?
Freeform Solutions provides technology and management consulting, website and database development, and managed internet hosting solutions for not-for-profit organizations (NFPs).

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: amp config issue "Connection failed" when entering mysql_dsn
February 06, 2015, 07:21:17 am
Could you try changing "localhost" to "127.0.0.1"? It makes a difference in some environments (for reasons that escape me).

lolas

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
    • Freeform Solutions
  • CiviCRM version: Several
  • CMS version: Drupal
  • MySQL version: 5.1+
  • PHP version: Several
Re: amp config issue "Connection failed" when entering mysql_dsn
February 06, 2015, 07:40:54 am
Sorry I forgot to mention that I already also tried mysql://root:passwordforroot@127.0.0.1:3306 with the same result.
Freeform Solutions provides technology and management consulting, website and database development, and managed internet hosting solutions for not-for-profit organizations (NFPs).

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: amp config issue "Connection failed" when entering mysql_dsn
February 06, 2015, 08:06:56 am
If you run "amp config:get", what value shows up for "mysql_type"?

You can try setting the parameters via CLI ("amp config:get --mysql_type=dsn --mysql_dsn=mysql://user:pass@localhost:3306") then running "amp test". (Although, if "amp config" fails to connect to the DSN, then "amp test" should fail too.)

Dumb question: Is there any chance that your terminals/network/SSH/VM setup has you running the mysql client and amp in different environments?

When you connect via mysql client, are you explicitly setting the port - or letting the client pick a default connection mechanism? Different MySQL/PHP stacks twiddle the defaults in awkward ways. (Sometimes you get TCP; sometimes sockets; sometimes a standard port; sometimes a non-standard port.) For apples-to-apples comparison, try pass all connection criteria to mysql cli. (e.g. "mysql -h 127.0.0.1 -u myuser -pmypassword -P 3306 mydb")

What happens if you run this script?

Code: [Select]
<?php
$pdo 
= new PDO('mysql:host=localhost;dbname=FIXME_DB;port=3306;charset=utf8', 'FIXME_USER', 'FIXME_PASS');
foreach (
$pdo->query('select 99 as value') as $row) {
  if (
$row['value'] == 99) {
    echo 
"OK\n";
  } else {
    echo 
"Bad value\n";
  }
  exit();
}
echo 
"Missing response";

lolas

  • I post frequently
  • ***
  • Posts: 134
  • Karma: 9
    • Freeform Solutions
  • CiviCRM version: Several
  • CMS version: Drupal
  • MySQL version: 5.1+
  • PHP version: Several
Re: amp config issue "Connection failed" when entering mysql_dsn
February 21, 2015, 01:40:03 pm
Thanks!

I had a problem with PDO which your test code showed me. I forgot that I hadn't tested this machine in a while. I thought it was all setup but it had been re-installed and was missing some drivers.
Freeform Solutions provides technology and management consulting, website and database development, and managed internet hosting solutions for not-for-profit organizations (NFPs).

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • amp config issue "Connection failed" when entering mysql_dsn

This forum was archived on 2017-11-26.