This Help forum is for issues relates to webtrees 1.7. For issues related to webtrees 2.0, please use that forum.
Before asking for help please read "Requesting Help and Suggestions" by clicking on that tab above here."
  • Page:
  • 1

TOPIC:

Mysql login problem 3 weeks 2 days ago #1

  • janth
  • janth's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 110
When trying to open webtrees login page I get the following error in apache2 error.log.

Any suggestions what may be wrong ?

[Thu Sep 08 21:04:39.512146 2022] [php7:error] [pid 69142] [client 127.0.0.1:53992] PHP Fatal error: Uncaught Exception: No Connection Established in /home/webtrees-1.7.20/app/Database.php:275\nStack trace:\n#0 /home/webtrees-1.7.20/app/Log.php(48): Fisharebest\\Webtrees\\Database::prepare('INSERT INTO `##...')\n#1 /home/webtrees-1.7.20/app/Log.php(106): Fisharebest\\Webtrees\\Log::addLog('/home/webtrees-...', 'error')\n#2 /home/webtrees-1.7.20/includes/session.php(237): Fisharebest\\Webtrees\\Log::addErrorLog('/home/webtrees-...')\n#3 [internal function]: Fisharebest\\Webtrees\\{closure}(Object(ErrorException))\n#4 {main}\n thrown in /home/webtrees-1.7.20/app/Database.php on line 275

Please Log in or Create an account to join the conversation.

Mysql login problem 3 weeks 2 days ago #2

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 16321
It means that there was an error - and it couldn't be written to the database because the database connection has closed.

Basically, it could be anything.
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

Mysql login problem 3 weeks 2 days ago #3

  • janth
  • janth's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 110
I am using mysql 8.x on ubuntu 22.04 - is that incompatible with webtrees ?

Please Log in or Create an account to join the conversation.

Mysql login problem 3 weeks 1 day ago #4

  • janth
  • janth's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 110
i have tested php connectivity to the database with the following script and it works fine. I replaced the dbname, dbuser, dbpass, and dbhost with the relevant parameters and executed it as follows:

php7.3 -f connect-test.php
There are 32 tables<br />

So it appears the problem lies somehow in my apache2/php7.3 configuration. Any ideas would be welcome.

<?php
# Fill our vars and run on cli
# $ php -f db-connect-test.php

$dbname = 'name';
$dbuser = 'user';
$dbpass = 'pass';
$dbhost = 'host';

$link = mysqli_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");
mysqli_select_db($link, $dbname) or die("Could not open the db '$dbname'");

$test_query = "SHOW TABLES FROM $dbname";
$result = mysqli_query($link, $test_query);

$tblCnt = 0;
while($tbl = mysqli_fetch_array($result)) {
$tblCnt++;
#echo $tbl[0]."<br />\n";
}

if (!$tblCnt) {
echo "There are no tables<br />\n";
} else {
echo "There are $tblCnt tables<br />\n";
}
?>

Please Log in or Create an account to join the conversation.

Mysql login problem 3 weeks 1 day ago #5

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 16321
You could try modifying the code here:
github.com/fisharebest/webtrees/blob/1.7/app/Log.php#L47-L55

Instead of writing a message to the database, either write it to a file or display it on screen.

This might give you more clues...
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

Mysql login problem 3 weeks 1 day ago #6

  • janth
  • janth's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 110
Sorry, but I don't really know what to do with your suggestion ? Could you elaborate a little ?

Some additional information: I copied the db-connect-test.php script to /var/www/html and changed user and group to www-data, and accessed it via the url https://localhost/connect-test.php using firefox. And it worked. So it seems that there is no rights issues related to accessing my webtrees database using apache2/php7.3. Could it be that php7.3 apache code or webtrees code are incompatible with mysql version 8.0.30-0ubuntu0.22.04.1 ? I have previously used mysql 5.7 I believe and it worked fine.

Please Log in or Create an account to join the conversation.

Mysql login problem 3 weeks 1 day ago #7

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 16321
> Sorry, but I don't really know what to do with your suggestion ? Could you elaborate a little ?

The code is trying to write an error message to the database - but failing because the database connection is lost.

It would be helpful to know this error message.

So, I suggest modifying the code to replace the highlighted section with either
1) displaying the error on screen
2) writing the error to a file

You posted PHP code that you've written, so I'm assuming you know how to use "echo" and "file_put_contents()"...
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

Mysql login problem 3 weeks 1 day ago #8

  • janth
  • janth's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 110
I am afraid you have overestimated my skills. The script was from a website :-( and I just copied it. Your proposal looks great but I am afraid I need some more details:

1. is it an existing piece of webtrees code I need to change, and what is its name and location ?
2. or is it an entirely new piece of code, and if yes where should I put it ?
2. unfortunately I dont know how to do the proposed coding. I have coded a lot in my time but never php

Please Log in or Create an account to join the conversation.

Do you need a web hosting solution for your webtrees site?
If you prefer a host that specialises in webtrees, the following page lists some suppliers able to provide one for you: 

Mysql login problem 3 weeks 1 day ago #9

  • janth
  • janth's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 110
I have added phpinfo file which may give you a hint about any php modules missing etc.
Attachments:

Please Log in or Create an account to join the conversation.

Mysql login problem 3 weeks 1 day ago #10

  • janth
  • janth's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 110
I think I have figured it out. This is the error message :

/home/webtrees-1.7.20/includes/session.php:270 Undefined index: dbname #0 /includes/session.php:270 ErrorException("Undefined index: dbname") #1 /index.php:31 require('/home/webtrees-1.7.20/includes…') error

Please Log in or Create an account to join the conversation.

Mysql login problem 3 weeks 1 day ago #11

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 16321

I think I have figured it out. This is the error message :

/home/webtrees-1.7.20/includes/session.php:270 Undefined index: dbname #0 /includes/session.php:270 ErrorException("Undefined index: dbname") #1 /index.php:31 require('/home/webtrees-1.7.20/includes…') error

Perhaps your data/config.ini.php file is missing or incomplete...?

webtrees.net/faq/config-ini-php/
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

Mysql login problem 3 weeks 1 day ago #12

  • janth
  • janth's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 110
config.ini.php was there. Unfortunately I had forgotten to specify dbname parameter. After I entered this and restarted apache2 I get a new error message :

/home/webtrees-1.7.20/app/Statement.php:85 SQLSTATE[42S02]: Base table or view not found: 1146 Table 'myfamily.wt_site_access_rule' doesn't exist #0 /app/Statement.php:85 PDOException("SQLSTATE[42S02]: Base table or view not found: 1146 Table 'myfamily.wt_site_access_rule' doesn't exist") #1 /includes/session.php:315 execute([array]) #2 /index.php:31 require('/home/webtrees-1.7.20/includes…') /home/webtrees-1.7.20/app/Statement.php:85 SQLSTATE[42S02]: Base table or view not found: 1146 Table 'myfamily.wt_site_access_rule' doesn't exist #0 /app/Statement.php:85 PDOException("SQLSTATE[42S02]: Base table or view not found: 1146 Table 'myfamily.wt_site_access_rule' doesn't exist") #1 /includes/session.php:315 execute([array]) #2 /index.php:31 require('/home/webtrees-1.7.20/includes…') error

Please Log in or Create an account to join the conversation.

Mysql login problem 3 weeks 1 day ago #13

  • janth
  • janth's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 110
Now I searched the forum for wt_site_access_rule, and it appears it is not included in webtrees 2.x onwards. I did check myql and it is indeed missing. So the most logical conclusion seems to be that my backup is NOT a 1.7.x backup as I thought. It is most likely a 2.0.19 backup. Is there any way to look in the .sql file to see which version of webtrees that was backed up ?

Please Log in or Create an account to join the conversation.

Mysql login problem 3 weeks 1 day ago #14

  • janth
  • janth's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 110
Problem finally solved. It was too long ago that I have used the database and the host that ran webtrees died. Luckily I have backups but I remembered incorrectly that it was 1.7.x and not 2.0.19. After installin 2.0.19 and fixing config.ini.php with the forgotten database name and added the url I can now log in and it appears to work as it should.

Thank you for helping me out with this problem :-)

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum