[Meta] Running Drupal with read only DB user (working title)

Created on 3 March 2022, about 3 years ago
Updated 13 September 2024, 8 months ago

Problem/Motivation

When switching to a read only DB user on an environment with memcache or redis, there's various fatal errors due to code. Detailed description follows.

Steps to reproduce

On a vanilla Drupal and ddev local environment:

Mysql commands

  • REVOKE ALL, GRANT OPTION FROM db@localhost;
  • REVOKE ALL, GRANT OPTION FROM db@'%';
  • SHOW GRANTS FOR db@localhost;
  • Show grants for db@'%';
  • GRANT SELECT, SHOW VIEW ON db.* TO 'db'@'localhost';
  • GRANT SELECT, SHOW VIEW ON db.* TO 'db'@'%';

Steps to replicate:

  • Execute mysql commands above after connecting to the DB using ddev mysql -u root -p (pw root)
  • Make sure the DB user and PW in settings.local.php/settings.ddev.php is root/root
  • Comment the cache bin definition in settings.local.php which makes bins to store in memcache
//$settings['cache']['bins']['config'] = 'cache.backend.memcache';
//$settings['cache']['bins']['bootstrap'] = 'cache.backend.memcache';
//$settings['cache']['bins']['data'] = 'cache.backend.memcache';
//$settings['cache']['bins']['discovery'] = 'cache.backend.memcache';
//$settings['cache']['bins']['default'] = 'cache.backend.memcache';
//$settings['cache']['bins']['render'] = 'cache.backend.memcache';
//$settings['cache']['bins']['entity'] = 'cache.backend.memcache';
//$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.memcache';
//$settings['cache']['bins']['page'] = 'cache.backend.memcache';
//$settings['cache']['bins']['menu'] = 'cache.backend.memcache';
//$settings['cache']['bins']['toolbar'] = 'cache.backend.memcache';

  • ddev drush si -y
  • ddev drush en -y memcache
  • In settings.php add
$settings['memcache']['servers'] = ['memcache:11211' => 'default'];
$settings['cache']['bins']['config'] = 'cache.backend.memcache';
$settings['cache']['bins']['bootstrap'] = 'cache.backend.memcache';
$settings['cache']['bins']['data'] = 'cache.backend.memcache';
$settings['cache']['bins']['discovery'] = 'cache.backend.memcache';
$settings['cache']['bins']['default'] = 'cache.backend.memcache';
$settings['cache']['bins']['render'] = 'cache.backend.memcache';
$settings['cache']['bins']['entity'] = 'cache.backend.memcache';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.memcache';
$settings['cache']['bins']['page'] = 'cache.backend.memcache';
$settings['cache']['bins']['menu'] = 'cache.backend.memcache';
$settings['cache']['bins']['toolbar'] = 'cache.backend.memcache';
  • ddev drush pmu -y dblog
  • ddev drush uli and login with the login link
  • ddev drush cr
  • Change the DB user and PW in settings.local.php/settings.ddev.php is db/db
  • Navigate to home or /node/add/article and observe errors as described in child issues

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Feature request
Status

Closed: won't fix

Version

11.0 🔥

Component
Other 

Last updated about 11 hours ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024