Drupal 8 connection getting PDO permission denied - pdo

I am new to Drupal 8 and am starting by building a sample site. I have everything setup right, but I'm getting the PDO connection error below. I'm pretty sure it has to do with hostname but I can't figure out what.
My settings.php looks like this:
$databases['default']['default'] = array (
'database' => 'website_pet',
'username' => 'drupal',
'password' => 'mypass',
'host' => '127.0.0.1',
'port' => '3306',
'driver' => 'mysql',
'prefix' => '',
'collation' => 'utf8mb4_general_ci',
);
And in my.cnf I have added:
max_allowed_packet=100M
And my httpd error log shows:
[Fri Jun 07 03:47:32.183065 2019] [php7:notice] [pid 19631] [client
::1:58796] PDOException: SQLSTATE[HY000] [2002] Permission denied in
/var/www/html/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php
on line 79 #0
/var/www/html/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php(420):
PDO->__construct('mysql:host=127....', 'drupal', 'mypass', Array)\n#1
/var/www/html/core/lib/Drupal/Core/Database/Database.php(371):
Drupal\Core\Database\Driver\mysql\Connection::open(Array)\n#2
/var/www/html/core/lib/Drupal/Core/Database/Database.php(166):
Drupal\Core\Database\Database::openConnection('default',
'default')\n#3 [internal function]:
Drupal\Core\Database\Database::getConnection('default')\n#4
/var/www/html/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php(79):
call_user_func_array('Drupal\\Core\\Dat...', Array)\n#5
/var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php(171):
Drupal\Component\DependencyInjection\PhpArrayContainer->createService(Array,
'database')\n#6
/var/www/html/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php(260):
Drupal\Component\DependencyInjection\Container->get('database',
1)\n#7
/var/www/html/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php(62):
Drupal\Component\DependencyInjection\PhpArrayContainer->resolveServicesAndParameters(Array)\n#8
/var/www/html/core/lib/Drupal/Component/DependencyInjection/Container.php(171):
Drupal\Component\DependencyInjection\PhpArrayContainer->createService(Array,
'cache.container')\n#9
/var/www/html/core/lib/Drupal/Core/DrupalKernel.php(543):
Drupal\Component\DependencyInjection\Container->get('cache.container')\n#10
/var/www/html/core/lib/Drupal/Core/DrupalKernel.php(904):
Drupal\Core\DrupalKernel->getCachedContainerDefinition()\n#11
/var/www/html/core/lib/Drupal/Core/DrupalKernel.php(476):
Drupal\Core\DrupalKernel->initializeContainer()\n#12
/var/www/html/core/lib/Drupal/Core/DrupalKernel.php(692):
Drupal\Core\DrupalKernel->boot()\n#13 /var/www/html/index.php(19):
Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))\n#14
{main}, referer: http://localhost:1180/core/install.php
I can connect to the database through both:
mysql -u drupal -pmypass -h 127.0.0.1 website_pet
mysql -u drupal -pmypass -h localhost website_pet
so I know it's not a permission error to the database. The website is hosted in the cloud, and I'm accessing it through a SSH tunnel (localhost:1180). If have tried setting selinux to permissive temporarily but that didn't help.
Can someone point to what's wrong with this?
UPDATE: After some restarts etc the error changes a bit, the webpage shows:
Additional uncaught exception thrown while handling exception.
Original
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: CREATE TABLE {cache_default} ( `cid` VARCHAR(255) CHARACTER SET ascii BINARY NOT NULL DEFAULT '' COMMENT 'Primary Key: Unique cache ID.', `data` LONGBLOB NULL DEFAULT NULL COMMENT 'A collection of data to cache.', `expire` INT NOT NULL DEFAULT 0 COMMENT 'A Unix timestamp indicating when the cache entry should expire, or -1 for never.', `created` DECIMAL(14, 3) NOT NULL DEFAULT 0 COMMENT 'A timestamp with millisecond precision indicating when the cache entry was created.', `serialized` SMALLINT NOT NULL DEFAULT 0 COMMENT 'A flag to indicate whether content is serialized (1) or not (0).', `tags` LONGTEXT NULL DEFAULT NULL COMMENT 'Space-separated list of cache tags for this entry.', `checksum` VARCHAR(255) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL COMMENT 'The tag invalidation checksum when this entry was saved.', PRIMARY KEY (`cid`), INDEX `expire` (`expire`), INDEX `created` (`created`) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT 'Storage for the cache API.'; Array ( ) in Drupal\views\ViewsData->cacheSet() (line 209 of /var/www/html/core/modules/views/src/ViewsData.php).
Drupal\views\ViewsData->cacheSet('views_data', Array) (Line: 257)
Drupal\views\ViewsData->getData() (Line: 160)
Drupal\views\ViewsData->get('block_content') (Line: 91)
Drupal\views\Plugin\Derivative\ViewsEntityRow->getDerivativeDefinitions(Array) (Line: 101)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives(Array) (Line: 87)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions() (Line: 284)
Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 175)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 147)
views_theme(Array, 'module', 'views', 'core/modules/views') (Line: 447)
Drupal\Core\Theme\Registry->processExtension(Array, 'views', 'module', 'views', 'core/modules/views') (Line: 334)
Drupal\Core\Theme\Registry->build() (Line: 233)
Drupal\Core\Theme\Registry->get() (Line: 86)
Drupal\Core\Utility\ThemeRegistry->initializeRegistry() (Line: 67)
Drupal\Core\Utility\ThemeRegistry->__construct('theme_registry:runtime:seven', Object, Object, Array, 1) (Line: 253)
Drupal\Core\Theme\Registry->getRuntime() (Line: 142)
Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 437)
Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, 1) (Line: 139)
Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 140)
Drupal\Core\Render\Renderer->renderRoot(Array) (Line: 66)
Drupal\Core\Render\BareHtmlPageRenderer->renderBarePage(Array, Object, 'install_page', Array) (Line: 76)
Drupal\Core\ProxyClass\Render\BareHtmlPageRenderer->renderBarePage(Array, Object, 'install_page', Array) (Line: 1067)
install_display_output(Array, Array) (Line: 167)
install_drupal(Object) (Line: 44)
Additional
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: CREATE TABLE {cache_default} ( `cid` VARCHAR(255) CHARACTER SET ascii BINARY NOT NULL DEFAULT '' COMMENT 'Primary Key: Unique cache ID.', `data` LONGBLOB NULL DEFAULT NULL COMMENT 'A collection of data to cache.', `expire` INT NOT NULL DEFAULT 0 COMMENT 'A Unix timestamp indicating when the cache entry should expire, or -1 for never.', `created` DECIMAL(14, 3) NOT NULL DEFAULT 0 COMMENT 'A timestamp with millisecond precision indicating when the cache entry was created.', `serialized` SMALLINT NOT NULL DEFAULT 0 COMMENT 'A flag to indicate whether content is serialized (1) or not (0).', `tags` LONGTEXT NULL DEFAULT NULL COMMENT 'Space-separated list of cache tags for this entry.', `checksum` VARCHAR(255) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL COMMENT 'The tag invalidation checksum when this entry was saved.', PRIMARY KEY (`cid`), INDEX `expire` (`expire`), INDEX `created` (`created`) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT 'Storage for the cache API.'; Array ( ) in Drupal\views\ViewsData->cacheSet() (line 209 of /var/www/html/core/modules/views/src/ViewsData.php).
Drupal\views\ViewsData->cacheSet('views_data:block_content', Array) (Line: 176)
Drupal\views\ViewsData->get('block_content') (Line: 91)
Drupal\views\Plugin\Derivative\ViewsEntityRow->getDerivativeDefinitions(Array) (Line: 101)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives(Array) (Line: 87)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions() (Line: 284)
Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 175)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 147)
views_theme(Array, 'module', 'views', 'core/modules/views') (Line: 447)
Drupal\Core\Theme\Registry->processExtension(Array, 'views', 'module', 'views', 'core/modules/views') (Line: 334)
Drupal\Core\Theme\Registry->build() (Line: 233)
Drupal\Core\Theme\Registry->get() (Line: 86)
Drupal\Core\Utility\ThemeRegistry->initializeRegistry() (Line: 67)
Drupal\Core\Utility\ThemeRegistry->__construct('theme_registry:runtime:seven', Object, Object, Array, 1) (Line: 253)
Drupal\Core\Theme\Registry->getRuntime() (Line: 142)
Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 437)
Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, 1) (Line: 139)
Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 140)
Drupal\Core\Render\Renderer->renderRoot(Array) (Line: 66)
Drupal\Core\Render\BareHtmlPageRenderer->renderBarePage(Array, 'Error', 'install_page', Array) (Line: 76)
Drupal\Core\ProxyClass\Render\BareHtmlPageRenderer->renderBarePage(Array, 'Error', 'install_page', Array) (Line: 1067)
install_display_output(Array, Array, Array) (Line: 260)
_drupal_log_error(Array, 1) (Line: 602)
_drupal_exception_handler(Object)

There is a high chance this is SELinux gets involved into. Suppose because you are using 127.0.0.1 instead of localhost? I've had exactly the same error (but I'm really tried to connect to a remote host) and this answer helped me.
Thus, to be shortly:
setsebool -P httpd_can_network_connect_db 1

After much experimentation the problem sees to stem from installing PHP 7.2 on CentOS 7. (Which only ships with PHP 5.x)
Could never get it to work, but after building a new ubuntu which includes PHP 7 all seemed to work.
I could not trace this down to a single module/setting/package. But the solution is don't attempt on CentOS 7 (using remi repo for PHP7x packages)

First of all, it's a bad idea to use the root user for Drupal - should somebody find a weakness you've just let them access to everything on your database, and probably the rest of the system too. While this might be a dev system it is unwise to get into bad habits.
Anyway on to the issue. One thing to be aware of with MySQL is that localhost connections are normally diverted via a Unix domain Socket (i.e. a "file" in the filesystem) for performance reasons. Sometimes you get a permission denied failure because the socket is not present or is not accessible to the user making the connection, or the user has included "localhost" in the MySQL permissions table when it should be "127.0.0.1" or vice versa. Finally, in this mix, with IPv6, some OS network stacks now default to "::1" (the IPv6 equivalent of 127.0.0.1) instead.
Double check what the DB permissions table contains: all three (host, user, password) must match for access to be granted. My experience is that the wildcard-host: "%" is not reliable, so I avoid using it.
You could try setting the 127... to "localhost" in both drupal and in the permissions table in MySQL.
HTH

Related

OPENDJ: LDAP: SCHEMA: [Unable to register attribute type name with the server schema...]

I keep getting the following error on restart of the opendj service. bin/stop-ds --restart.
[20/Dec/2022:15:32:30 -0500] category=CORE severity=NOTICE msgID=134 msg=OpenDJ Server 4.4.11 (build 20210621115558, revision number 3f83673) starting up
[20/Dec/2022:15:32:30 -0500] category=CONFIG severity=WARNING msgID=761 msg=The config schema file '04-rfc2307bis.ldif' generated warning when trying to update schema with its content: [Unable to register attribute type name with the server schema because its OID 2.5.4.41 conflicts with the OID of an existing attribute type name]
bin/stop-ds --restart
egrep -R 2.5.4.41 /opt/opendj/config/schema
04-rfc2307bis.ldif:attributeTypes: ( 2.5.4.41 NAME 'name' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'RFC 4519' X-SCHEMA-FILE '00-core.ldif' )
00-core.ldif:attributeTypes: ( 2.5.4.41 NAME 'name' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 X-ORIGIN 'RFC 4519' X-SCHEMA-FILE '00-core.ldif' )
I've tried removing the duplicate attributeType with ldapmodify and manually removing from the schema files. The duplicates always come back.
Expected behavior
When restarting OpenDJ, there should be normal output and no WARNINGS about duplicate OIDs.
OS: RHEL 7.9
Version: 4.4.11
Additional context
I noticed the file /opt/opendj/config/upgrade/schem.ldif.current was not synced with my replica. I removed both files and created empty ones. Restart OpenDJ, the error goes away for a few minutes then comes back every time. What can I do to resolve this?
Sorry for any confusion. I believe I've solved this as a "user error".
I had a custom schema file not prepended with "99-". After adding the correct prefix things seem to be working as expected. Closing.

ldapmodify: invalid format when trying to create olcObjectClass-

I'm trying to adda new object class to OpenLDAP and getting the following error, but can't see the issue:
# Add the securityPrincipal class
dn: cn={0}core,cn=schema,cn=config
changetype: modify
add: olcObjectClasses
olcObjectClasses: ( 1.2.840.113556.1.5.6 NAME 'securityPrincipal'
DESC: 'Contains the security information for an object.'
SUP top AUXILIARY
MUST ( $ sAMAccountName )
MAY ( )
)
This is the error:
ldapmodify: invalid format (line 38) entry: "cn={0}core,cn=schema,cn=config"
which refers to this line:
olcObjectClasses: ( 1.2.840.113556.1.5.6 NAME 'securityPrincipal'
I found the issue by putting everything on the same line and then the error was much clearer

Issue with creation of SSL key via ansible

Please help to understand why this task is not working for me?
---
- name: Generation of SSL key
openssl_privatekey:
path: "/opt/mongodbkey"
size: 741
force: true
My error :
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
The error appears to have been in '/root/mongodb/roles/mongodb/tasks/ssl.yml': line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- name: Generation of SSL key
^ here
Also one more quick question. Is it right method for this manual command?
openssl rand -base64 741 > /opt/mongodbkey

Ansible docker invalid character %

I am writing some ansible to automate my docker deployments.
I am trying to set an env variable to be % but I get this error:
ERROR! Syntax Error while loading YAML.
found character that cannot start any token
The error appears to have been in '/vagrant/roles/zoneminder_docker/tasks/main.yml': line 21, column 24, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
MYSQL_ROOT_PASSWORD: mysqlpsswd
MYSQL_ROOT_HOST: %
^ here
Is there any way to escape this character? As if I exclude this line, my deployment fails.
Is there any way to escape this character? As if I exclude this line, my deployment fails.
The thing you are looking for is to make that value a string literal:
MYSQL_ROOT_PASSWORD: mysqlpsswd
MYSQL_ROOT_HOST: '%'

xpages dojo calendar script SyntaxError: missing ; before statement

Hello I'm receiving the following js error within my xpages app. It is in relation to the calendar widget. Oddly enough this code runs on a server perfectly fine, however when I try accessing the same server, same app through a firewall, that's when I receive the following js error. Unfortunately this is compressed js and I don't know what anything is doing to be able to resolve the issue on my own. Any help would be greatly appreciated.
failed loading /xsp/.ibmxspres/dojoroot-1.6.1/dojo/../dijit/Calendar.js with error: SyntaxError: missing ; before statement
https://newwads.health.state.ny.us/+CSCO+d6756767633A2F2F7565766665696534++/xsp/.ibmxspres/dojoroot-1.6.1/dojo/dojo.js
Line 14
failed loading /xsp/.ibmxspres/dojoroot-1.6.1/dojo/../dijit/Calendar.js with error: SyntaxError: missing ; before statement
toString(uri=
undefined
, _25=
undefined
, cb=
undefined
)dojo.js (line 14)
toString(_21=
"../dijit/Calendar.js"
, _22=
"dijit.Calendar"
, cb=
undefined
)dojo.js (line 14)
toString(_2d=
"dijit.Calendar"
, _2e=
undefined
)dojo.js (line 14)
eval()56 (line 8)
toString(_1d=
"/*\r\n Copyright (c) 2004...jit/form/DateTextBox.js"
)dojo.js (line 14)
toString(uri=
"/xsp/.ibmxspres/dojoroo...jit/form/DateTextBox.js"
, cb=
undefined
)dojo.js (line 14)
toString(uri=
"/xsp/.ibmxspres/dojoroo...jit/form/DateTextBox.js"
, _25=
"dijit.form.DateTextBox"
, cb=
undefined
)dojo.js (line 14)
toString(_21=
"../dijit/form/DateTextBox.js"
, _22=
"dijit.form.DateTextBox"
, cb=
undefined
)dojo.js (line 14)
toString(_2d=
"dijit.form.DateTextBox"
, _2e=
undefined
)dojo.js (line 14)
()testTime.xsp (line 21)
...dium"){return 4;}if(_171.slice&&_171.slice(-2)=="px"){return parseFloat(_171);}w...
Is your proxy messing with the data? Like single-signon or adding code? You could use Fiddler and see what is going on. Also AFAIK the FF WebDeveloper allows to see the loaded JS uncompressed