如何在 lando 环境中使用 mysql 命令?

如何在 lando 环境中使用 mysql 命令?

我尝试在专用于 drupal 安装的 lando 容器中运行的脚本中测试一些不同的 mysql 命令。我按照入门指南。除了 mysql 命令之外,一切都运行正常。当我通过 登录容器lando ssh并尝试运行普通命令mysql -u drupal9 -p并输入我的密码时,我得到了一个ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)。我尝试lando rebuild安装mysql-server,但没有安装候选项,所以我怀疑我必须向 lando 配置添加更多信息,因为执行 的经典方式lando mysql正在运行,所以我假设数据库无法从 lando drupal 容器内访问。这是lando info。它从主机系统内部加载 mysql 配置,而不是从客户系统加载。所以这就是我怀疑我必须在配置中更改某些内容的原因。

[ { service: 'appserver',
    urls:
     [ 'https://localhost:32835',
       'http://localhost:32836',
       'http://test.lndo.site:8000/',
       'https://test.lndo.site/' ],
    type: 'php',
    healthy: true,
    via: 'apache',
    webroot: 'web',
    config: { php: '/home/USER/.lando/config/drupal9/php.ini' },
    version: '8.0',
    meUser: 'www-data',
    hasCerts: true,
    hostnames: [ 'appserver.test.internal' ] },
  { service: 'database',
    urls: [],
    type: 'mysql',
    healthy: true,
    internal_connection: { host: 'database', port: '3306' },
    external_connection: { host: '127.0.0.1', port: '32834' },
    healthcheck: 'bash -c "[ -f /bitnami/mysql/.mysql_initialized ]"',
    creds: { database: 'drupal9', password: 'drupal9', user: 'drupal9' },
    config: { database: '/home/USER/.lando/config/drupal9/mysql.cnf' },
    version: '5.7',
    meUser: 'www-data',
    hasCerts: false,
    hostnames: [ 'database.test.internal' ] } ]

如何在容器内的 lando 环境中使用 mysql 命令lando ssh

编辑我:

这是本地的.cnf文件

# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 0. "/etc/mysql/my.cnf" symlinks to this file, reason why all the rest is read.
# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# If you are new to MariaDB, check out https://mariadb.com/kb/en/basic-mariadb-articles/

#
# This group is read both by the client and the server
# use it for options that affect everything
#
[client-server]
# Port or socket location where to connect
# port = 3306
socket = /run/mysqld/mysqld.sock

# Import all .cnf files from configuration directory
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/

我也尝试安装mariadb-server但问题仍然一样。

相关内容