The Backdrop CMS community has been planning to integrate an installation of CiviCRM to BackdropCMS.org for a while. I've decided to get the ball rolling by attempting to add CiviCRM to a local version of BackdropCMS, using Lando. 

I seem to be having problems connecting to the database. Here is the portion of the of the 'lando info' return related to the civiccrm database. 

  { service: 'cividatabase',
    urls: [],
    type: 'mariadb',
    healthy: true,
    internal_connection: { host: 'cividatabase', port: '3306' },
    external_connection: { host: '127.0.0.1', port: 3309 },
    healthcheck: 'mysql -uroot --silent --execute "SHOW DATABASES;"',
    creds: { database: 'cividatabase', password: null, user: 'root' },
    config: {},
    version: '10.3',
    meUser: 'www-data',
    hasCerts: false,
    hostnames: [ 'cividatabase.borg.internal' ] },

I'm on the CiviCRM installer page and getting this message
"Does the server exist?           Can't find the a MySQL server on 'cividatabase'.: Connection refused"

So, what do I put in here to help CiviCRM installer find the database?

I found this blog post, but it doesn't seem to answer my question: https://thinktandem.io/blog/2017/12/18/lando-backdrop-civicrm/

Accepted answer

@laryn - I though of that too, but was too lazy to try - until you prodded me.

The problem is that the blog post I referenced said, that it was not currently possible to set the password with the .lando.yml file and the author suggested leaving it blank. The sample code I had looked like this:

cividatabase:
    type: mariadb
    portforward: 6619
    creds:
      user: root
      password:
      database: cividatabase

If I tried to give it a password in the .lando.yml file and it didn't work. But, I found another sample .lando.yml file that defined the database without setting creds. It looked like this:

cividatabase:
    type: mariadb
    portforward: 6619

So, then I created the environment without trying to specify a user, password, and database name. The username, password, and database name were set automatically and I was able to access them with

'lando info'

Then I entered these credentials in the CiviCRM installation page and it worked.

NOTE: To install CiviCRM

1) Add the CiviCRM package to the modules directory and then

2) Go to this page. http://{mywebsite.com}/modules/civicrm/install/index.php?civicrm_install_type=backdrop

As per instructions found here.

Most helpful answers

I use the command: lando db-import --no-wipe db.sql.gz then it won't overwrite.

I usually just dump all the civi tables in the backdrop db. On live I keep them separate usually.

The clean URLs is buggy in Lando. Need to debug that. Maybe I'll do it with the current upgrade I'm working on.

Comments

You could try to install it into the same database as Backdrop. @herb indicated that's okay to do.

Thanks @Laryn

I just spun up a generic copy of BackdropCMS and CiviCRM on my dev server and didn't have any problems connecting the second database. So, the problem is definitely related to Lando and understanding how to connect to a second database. Hopefully someone with some Lando knowledge can help out. 

In my local Lando installation, I tried just using the same database as you suggested and that worked. But, for some reason, I still like the idea of using two databases and am hoping to figure out how to do that with Lando (again, it was no problem on my dev server). 

 

Have you tried giving the database user a password instead of NULL? Just guessing.

@laryn - I though of that too, but was too lazy to try - until you prodded me.

The problem is that the blog post I referenced said, that it was not currently possible to set the password with the .lando.yml file and the author suggested leaving it blank. The sample code I had looked like this:

cividatabase:
    type: mariadb
    portforward: 6619
    creds:
      user: root
      password:
      database: cividatabase

If I tried to give it a password in the .lando.yml file and it didn't work. But, I found another sample .lando.yml file that defined the database without setting creds. It looked like this:

cividatabase:
    type: mariadb
    portforward: 6619

So, then I created the environment without trying to specify a user, password, and database name. The username, password, and database name were set automatically and I was able to access them with

'lando info'

Then I entered these credentials in the CiviCRM installation page and it worked.

NOTE: To install CiviCRM

1) Add the CiviCRM package to the modules directory and then

2) Go to this page. http://{mywebsite.com}/modules/civicrm/install/index.php?civicrm_install_type=backdrop

As per instructions found here.

I usually just dump all the civi tables in the backdrop db. On live I keep them separate usually.

The clean URLs is buggy in Lando. Need to debug that. Maybe I'll do it with the current upgrade I'm working on.

@herb - Just to be clear. If I understand you correctly, you are saying that on a live site you (often) keep the CiviCRM data in a separate database, but when working on the same site locally with Lando you dump the data into the same database with the Backdrop site.

Is there a special trick for doing this? I would expect that when I try to import the CiviCRM tables from a different database that it would overwrite or dump the existing data. I guess, this is never something I've tried before. 

I use the command: lando db-import --no-wipe db.sql.gz then it won't overwrite.

I'd like to share my .lando.yml file for building a Backdrop CiviCRM site on Lando.

Note that the CiviCRM installer has changed in recent versions so that you only need to enable the CiviCRM module and it will redirect you to the installer. Previously you had to first install and then enable the module (it's easier now).

My .lando.yml:

name: bd-civi
recipe: backdrop
config:
  webroot: .
  backdrush: 1.x-1.x
  via: nginx
proxy:
  mailhog:
    - mail.bd-civi.lndo.site
  phpmyadmin:
    - db.bd-civi.lndo.site
services:
  civicrm:
    type: mysql
  phpmyadmin:
    type: phpmyadmin
    hosts:
      - database
      - civicrm
  mailhog:
    type: mailhog
    hogfrom:
      - appserver
tooling:
  drush:
    service: appserver
    cmd: drush --root=/app --uri=https://bd-civi.lndo.site

Note that it's fairly easy to have a second database and both databases are accessible via phpmyadmin (via different hosts).

You can use mailhog to check emails going out.

And it has the latest Backdrop drush extension with the URL hardcoded in the last line so that "drush uli" works properly.

And finally it uses the nginx webserver since I've currently had issues with Apache with this combo.