database connection fail

database connection fail

by Tech Gyan -
Number of replies: 6

error msg database connection is fail

Can any one please help in that

in confg.php

used $CFG->dbtype    = 'mariadb';  and this also          $CFG->dbtype    = 'mysqli';

still error occur in sometime 

·


Average of ratings: -
In reply to Tech Gyan

Re: database connection fail

by Ken Task -
Picture of Particularly helpful Moodlers

Not enough info .... :|

Not only DB type ... but DB host.   Local or another machine.  DB user.  User have prev's to do Moodle?   Where and how are you hosted?   With whom?

Version of Moodle?

Have you a tool to check db for moodle ... like cPanel or do you have access to server where you could use mysql client from command line?

Can DB do utf8mb4 character set/collation ....

'SoS', Ken

In reply to Tech Gyan

Re: database connection fail

by Shail Jai -
Hi Akshya, 
one quick question... 

are you facing this issue for a particular course or for whole system ( your screenshot pointing out for a course that's why I have this question)?

if host, usename , password everything is correct then check if your database user have permission to access the database (this is applicable only if you are facing issue for complete system).

To give the access to user you can use grant command in linux and in window you have phpmyadmin or any database administration utility. I believe your mysql service is in running mode.
In reply to Shail Jai

Re: database connection fail

by Tech Gyan -
sir database is connected
m using site
just this msg comes sometimes
In reply to Tech Gyan

Re: database connection fail

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

As Ken says, we need more information. What database type and version is this? Is the database on the Moodle web server or a different server?

Check Connection_errors_max_connections in the global status, this should be 0, e.g.:

SHOW GLOBAL STATUS LIKE 'Connection_errors_max_connections';
+-----------------------------------+-------+
| Variable_name                     | Value |
+-----------------------------------+-------+
| Connection_errors_max_connections | 0     |
+-----------------------------------+-------+

If it's non-zero, check max_connections:

SHOW GLOBAL VARIABLES LIKE 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 151   |
+-----------------+-------+

This can be increased with SET GLOBAL max_connections = 200 (or more than 200) and adding max_connections = 200 to the database configuration file to make it persistent. Your hosting provider may manage this setting in which case you would need to contact them.