Database Failure - No such file or directory

Hello Guys,

I really need your assistance here. I am out of my wits here. So here is a brief.

I migrated this PHP app from a shared hosting to AWS. Everything was working fine, until I did something (sadly can’t remember what I did).

Here is the detail of the log file -

Fri Jun 5 04:21:32 2020 [44629][-none-][FATAL] Could not connect to DB server localhost as jatas_cms. port : No such file or directory

DB name = jatas_cms
DB user = jatas
Host = localhost

The user jatas is granted ALL PRIVILEGES to the DB.

Since I am using an Ubuntu instance, the default user is ‘Ubuntu’ which is added to www-data Group.

Let me know if you guys need any other information from me regarding this case.

Additional Info:
Screenshot 2020-06-05 at 1.37.04 PM Screenshot 2020-06-05 at 1.36.13 PM

Hi @jalex,

Check the details found here are correct;

Open config.php in a text editor

Search for the values db_ which should produce a list like

You should be able to update the password in the CRM by opening the file called “config.php”

In this file there will be an array called dbconfig that looks like:

'dbconfig' => 
  array (
    'db_host_name' => '',
    'db_host_instance' => '',
    'db_user_name' => '',
    'db_password' => '',
    'db_name' => '',
    'db_type' => '',
    'db_port' => '',
    'db_manager' => '',

If the details here are correct please check the PHP access and error logs for any information that may be related and provided them here :+1:

Hi Mac-Rae,

the array looks alright -

 array (
'db_host_name' => 'localhost',
'db_host_instance' => 'SQLEXPRESS',
'db_user_name' => 'jatas',
'db_password' => '(password)',
'db_name' => 'jatas_cms',
'db_type' => 'mysql',
'db_port' => '3306',
'db_manager' => 'MysqliManager',
'collation' => 'utf8_general_ci',
'charset' => 'utf8',

),

What type of database are you using?
If its MariaDB try changing db_host_name to mariadb

If not try login to MySQL and run the following query before choosing a database;

SHOW VARIABLES WHERE Variable_name = 'hostname';

Its MySQL not mariadb.

Also when I ran SHOW VARIABLES WHERE Variable_name = ‘hostname’;

It returns with the AWS private IP as value to hostname.

Maybe give the use of the IP a go, if not we’ll keep looking

Still the same error mate :slightly_frowning_face:

Fri Jun 5 04:28:07 2020 [45066][-none-][FATAL] Could not connect to DB server localhost as jatas_cms. port : No such file or directory

What is your Site_URL set to in the config.php file? Did you check for correct path?
Do you have .htacess file in the CRM Root ? what is the Base path set there?

Can you access you DB via some program on server like PHP MyAdmin ?
For AWS the host looks something like mysql–instance1.123456789012.us-east-1.rds.amazonaws.com so can you try to set your instance path in config
‘db_host_name’ => ‘YOUR_INSTANCE’,

1 Like

Hi Cherub-chum,

Here is the content of my .htaccess file

Contents of .HTACCESS File

BEGIN SUITECRM RESTRICTIONS

RedirectMatch 403 ..log$
RedirectMatch 403 /+not_imported_.
.txt
RedirectMatch 403 /+(soap|cache|xtemplate|data|examples|include|log4php|metadata|
modules|vendor)/+.*.(php|tpl)
RedirectMatch 403 /+emailmandelivery.php
RedirectMatch 403 /+.git
RedirectMatch 403 /+.cache/
RedirectMatch 403 /+tests
RedirectMatch 403 /+RoboFile.php
RedirectMatch 403 /+composer.json
RedirectMatch 403 /+composer.lock
RedirectMatch 403 /+upload
RedirectMatch 403 /+custom/+blowfish
RedirectMatch 403 /+cache/+diagnostic
RedirectMatch 403 /+files.md5$

Options +SymLinksIfOwnerMatch Options -Indexes Options -MultiViews RewriteEngine On RewriteBase /crm RewriteRule ^cache/jsLanguage/(.._..).js$ index.php?entryPoint=jslang&modulename=app_strings&lang=$1 [L,QSA] RewriteRule ^cache/jsLanguage/(\w*)/(.._..).js$ index.php?entryPoint=jslang&modulename=$1&lang=$2 [L,QSA]
# --------- DEPRECATED --------
RewriteRule ^api/(.*)$ - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^api/(.*?)$ lib/API/public/index.php/$1 [L]
# -----------------------------

RewriteRule ^Api/(.*)$ - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^Api/access_token$ Api/index.php/access_token [L]
RewriteRule ^Api/V8/(.*?)$ Api/index.php/V8/$1 [L]
Header unset ETag FileETag None Header unset X-Powered-By Header always unset X-Powered-By ExpiresActive on ExpiresDefault "access plus 1 month"

CSS

ExpiresByType text/css “access plus 1 year”

Data

ExpiresByType application/atom+xml “access plus 1 hour”
ExpiresByType application/rdf+xml “access plus 1 hour”
ExpiresByType application/rss+xml “access plus 1 hour”
ExpiresByType application/json “access plus 0 seconds”
ExpiresByType application/ld+json “access plus 0 seconds”
ExpiresByType application/schema+json “access plus 0 seconds”
ExpiresByType application/geo+json “access plus 0 seconds”
ExpiresByType application/xml “access plus 0 seconds”
ExpiresByType text/calendar “access plus 0 seconds”
ExpiresByType text/xml “access plus 0 seconds”

Favicon

ExpiresByType image/x-icon “access plus 1 week”

HTML

ExpiresByType text/html “access plus 0 seconds”

JavaScript

ExpiresByType application/javascript “access plus 1 year”
ExpiresByType application/x-javascript “access plus 1 year”
ExpiresByType text/javascript “access plus 1 year”

Markdown

ExpiresByType text/markdown “access plus 0 seconds”

Media files

ExpiresByType audio/ogg “access plus 1 month”
ExpiresByType image/bmp “access plus 1 month”
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
ExpiresByType image/jpg “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType image/svg+xml “access plus 1 month”
ExpiresByType image/webp “access plus 1 month”
ExpiresByType video/mp4 “access plus 1 month”
ExpiresByType video/ogg “access plus 1 month”
ExpiresByType video/webm “access plus 1 month”

Fonts

ExpiresByType font/eot “access plus 1 month”
ExpiresByType font/opentype “access plus 1 month”
ExpiresByType font/otf “access plus 1 month”
ExpiresByType application/x-font-ttf “access plus 1 month”
ExpiresByType font/ttf “access plus 1 month”
ExpiresByType application/font-woff “access plus 1 month”
ExpiresByType application/x-font-woff “access plus 1 month”
ExpiresByType font/woff “access plus 1 month”
ExpiresByType application/font-woff2 “access plus 1 month”
ExpiresByType font/woff2 “access plus 1 month”

Other

ExpiresByType text/x-cross-domain-policy “access plus 1 week”


Header set X-Content-Type-Options “nosniff”


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [R=301,L]

END SUITECRM RESTRICTIONS

AddHandler application/x-httpd-recommended-php .php .php5 .php4 .php3

The DB is not a RDS instance. It’s a simple MySQL server installed on the EC2 instance.

Regarding PHP MyAdmin - I can’t access it.

Can you set the Host in DB config to 127.0.0.1

Here is how you can add PhpMyAdmin to your EC2 instance

Hi Cherub,

I tried changing the host to 127.0.0.1 and still nothing.

Also PhpMyAdmin is installed just not working for some reason. Here is the link for your reference.

H Cherub, I fixed the issue :slight_smile:

So I ran sudo dpkg-reconfigure -plow phpmyadmin to fix the PhpMyAdmin issue. Once I had fixed phpMyAdmin I could see what the problem was. My database file was empty. Apparently I accidentally exported the new db (empty tables) over my existing sql file, instead of importing it the other way around… haha… I got it fixed now…

Thank you for all your troubles, and I am terribly sorry for the all inconvenience :slight_smile:

1 Like

Dear Cherub,

Everything is up and looks good, but the Quick Repair & Rebuild tool doesn’t work. I get the error Database failure. Please refer to suitecrm.log for details.

Is there something I am missing?
This is what the log says, I don’t see anything unusual, except that there is a missing relationship, which I built again.


Screenshot 2020-06-09 at 5.19.36 PM !

If you are migrating over and ‘rebuilding’ the instanced based on either a fresh database then you may need to take your time with the SQL repair & rebuild.

What I can see on your screen is there is a lot of SQL to execute. I would work your way through that SQL statement by statement so that you can rebuild the database in phases.

The error that is appears is the users_feed table. Perhaps execute the code (within that editable box) up until the users_feed and see if anything is wrong with the statement.

The alternative is to execute this SQL code in the PHPMyAdmin to see why it is failing. :slight_smile:

Hi Samus,
How can I do this? Is there a way i can just copy paste and run it all thru altogether? haha… or will I have to run it individually for each table? :slight_smile:

Perhaps not all the statements one by one but up until the users_feeds in the Repair & Rebuild screen you see. You could probably do it in chunks narrowing down the problematic tables.

Further to this. You could if you wanted execute the SQL in the Repair & Rebuild screen by click EXECUTE. That is why the text box with the SQL is editable. Else copy the SQL and inserted it via PHPMyAdmin console for that particular database.

Hi Samus,

So I tried running this on both backend and phpMyAdmin.

I saw that everytime it included the users_feeds table I got the error about Database Failure. But when I took it off and executed everything else, I get the status “Database Tables are synced with vardefs”.
What does that mean?

The user_feeds alter statement is as below

ALTER TABLE users_feeds modify COLUMN rank int(11) NULL ;

Yay. Glad you were able to get through the other SQL queries.

This is the problematic query because of the word “rank”. It’s a reserved word in MySQL.

There is a fuller discussion here on GitHub. https://github.com/salesagility/SuiteCRM/issues/6046

The immediate solution would be to manually execute this query via the Quick Repair & Rebuild field or PHPMyAdmin quotating the rank with backticks.

Screenshot_2020-06-11 Database Failure - No such file or directory

*seems discourse dislikes backticks as it uses it for code snippets XD

Oh on the final note the status of : Database Tables are synced with vardefs ” indicates that the databases have been rebuild matching the vardefs. and other defs. Meaning the two sources should be A-OK.

1 Like

Hey Samus,

I still get can’t repair from SuiteCRM. This is what the suitecrm.log show up.
Does it make sense?

Tue Jun 30 04:07:01 2020 [177858][1][FATAL] Mysqli_query failed.
Tue Jun 30 04:07:01 2020 [177858][1][FATAL] Executing repair query:  Query Failed: ALTER TABLE users_feeds   modify COLUMN rank int(11)  NULL: MySQL error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rank int(11)  NULL' at line 1
Tue Jun 30 04:07:01 2020 [177858][1][FATAL] Exception handling in /var/www/cms/include/MVC/Controller/SugarController.php:400
Tue Jun 30 04:07:01 2020 [177858][1][FATAL] Exception in Controller: Database failure. Please refer to suitecrm.log for details.
Tue Jun 30 04:07:01 2020 [177858][1][FATAL] backtrace:
#0 /var/www/cms/include/database/DBManager.php(353): sugar_die()
#1 /var/www/cms/include/database/DBManager.php(328): DBManager->registerError()
#2 /var/www/cms/include/database/MysqliManager.php(179): DBManager->checkError()
#3 /var/www/cms/modules/Administration/repairDatabase.php(95): MysqliManager->query()
#4 /var/www/cms/include/MVC/View/SugarView.php(834): include_once('/var/www/cms/mo...')
#5 /var/www/cms/include/MVC/View/views/view.classic.php(72): SugarView->includeClassicFile()
#6 /var/www/cms/include/MVC/View/SugarView.php(226): ViewClassic->display()
#7 /var/www/cms/include/MVC/Controller/SugarController.php(435): SugarView->process()
#8 /var/www/cms/include/MVC/Controller/SugarController.php(375): SugarController->processView()
#9 /var/www/cms/include/MVC/SugarApplication.php(113): SugarController->execute()
#10 /var/www/cms/index.php(52): SugarApplication->execute()
#11 {main}

Can you try running the query from phpMyAdmin?