MariaDB

MariaDB is a very common database server which is EXTREMELY similar to MySQL but has a guarantee of being open source. You can easily add it to your Lando app by adding an entry to the services key in your app's .lando.yml.

Supported versions

Be Careful Switching Database type, version or credentials

You should be careful switching database types, versions or credentials. In the case of type and version the underlying database files between these things may not be compatible. Ignoring this warning can cause your database service to not start correctly!!! In the case of credentials, these are set when the container is initially created so in order to change them you need to lando destroy && lando start. Note that lando destroy will delete all the data in your database.

You can read more about this here

Example

# The name of the app
name: mariadb

# Give me http://mariadb.lndo.site and https://mariadb.lndo.site
proxy:
  html:
    - mariadb.lndo.site

# Set up my services
services:

  # Set up a basic webserver running the latest nginx with ssl turned on
  html:
    type: nginx
    ssl: true
    webroot: www

  # Spin up a mariadb container called "database"
  # NOTE: "database" is arbitrary, you could just as well call this "db" or "kanye"
  database:

    # Use mariadb version 10.1
    type: mariadb:10.1

    # Optionally allow access to the database at localhost:3307
    # You will need to make sure port 3307 is open on your machine
    #
    # You can also set `portforward: true` to have Lando dynamically assign
    # a port. Unlike specifying an actual port setting this to true will give you
    # a different port every time you restart your app
    portforward: 3307

    # Optionally set the default db credentials
    #
    # Note: You will need to `lando destroy && lando start` to change these if you've
    # already started your app
    # See: https://docs.devwithlando.io/tutorials/lando-info.html
    creds:
      user: mariadb
      password: mariadb
      database: mariadb

    # Optionally load in all the mariadb config files in the config directory
    # This is relative to the app root
    # NOTE: these files need to end in .cnf
    config:
      confd: config

You will need to rebuild your app with lando rebuild to apply the changes to this file. You can check out the full code for this example over here.

Getting information

You can get connection and credential information about your database by running lando info from inside your app.

# Navigate to the app
cd /path/to/app

# Get info (app needs to be running to get this)
lando info

{
  "html": {
    "type": "nginx",
    "version": "latest",
    "urls": [
      "https://localhost:32802",
      "http://localhost:32803",
      "http://mariadb.lndo.site",
      "https://mariadb.lndo.site"
    ]
  },
  "database": {
    "type": "mariadb",
    "version": "10.1",
    "creds": {
      "user": "mariadb",
      "password": "mariadb",
      "database": "mariadb"
    },
    "internal_connection": {
      "host": "database",
      "port": 3306
    },
    "external_connection": {
      "host": "localhost",
      "port": 3307
    }
  }
}

results matching ""

    No results matching ""