Bug 24351 - During Installation, connection to remote mysql server fails
Summary: During Installation, connection to remote mysql server fails
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Installation and upgrade (command-line installer) (show other bugs)
Version: 19.05
Hardware: All All
: P1 - high major
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-06 12:44 UTC by Seema Albal
Modified: 2020-11-30 21:45 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Seema Albal 2020-01-06 12:44:02 UTC
Hi
I am installing Koha 19.11 on Debian 4.9. 
My SQL server is running on another instance. 

My my.cnf looks like this:
[client]
host=<remote ip>
user=root
password=xxxxx

I have successfully installed library instance using the koha-create --create-db <libraryname> command

This has installed a koha site in my apache2. However, the koha-conf.xml under /etc/koha/sites/<libraryname>/koha-conf.xml had db hostname as localhost. 
I have edited this to point to my sql server. 

However, when I do a wget localhost:8080 I still get an internal server error.

DBI Connect('database=<libraryname;host=localhost;port=3306','koha_libraryname',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 No such file or directory): /usr/share/koha/intranet/cgi-bin/mainpage.pl 

Please let me know where and how is the database server getting the default value of localhost.
Comment 1 Seema Albal 2020-01-06 15:30:22 UTC
Error message mentions it can't connect to local server while the SQL server is remote. 

mainpage.pl: DBI connect('database=koha_libraryname;host=localhost;port=3306','koha_libraryname',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory") at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1517.: /usr/share/koha/intranet/cgi-bin/mainpage.pl
Comment 2 Seema Albal 2020-01-06 16:37:20 UTC
And this is the error on the browser:

Software error:
DBIx::Class::Storage::DBI::catch {...} (): DBI Connection failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory") at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1520. at /usr/share/koha/lib/Koha/Database.pm line 107
Comment 3 David Nind 2020-01-06 19:24:42 UTC
Hopefully this will point you in the right direction to solve the problem you are having: https://wiki.koha-community.org/wiki/Install_Koha_3.6_on_Debian_squeeze_using_a_separate_MySQL_server

While it mentions Koha 3.6 I think it is still mostly correct.

Instead of using the sudo koha-create --create-db <libraryname> command you need to follow these steps:

1. sudo koha-create --request-db <libraryname>
2. Follow the instructions in the file created: create the database with the user name and password on your remote database server and set the required permissions.
3. Test that you can connect to the remote mysql server from your Koha server, for example: sudo mysql -u <username> -p -h <host-name-or-ip-address>. (Some database servers may be setup to not allow remote access, you will need to sort that out. You will need to install the database client packages on your Koha server.)
4. Populate the database: koha-create --populate-db <libraryname>
5. Carry on with your Koha installation...

If this doesn't work, I would post a message to the Koha mailing list or try the IRC channel.

If it does work, please post a comment as appropriate.

Notes:

* You may need to revert any changes you may have made, such as changes to my.cnf or Apache
* You will need to delete the instance you have created: sudo koha-remove <libraryname>
* I assume you didn't mean you were installing on Debian 4.9 (a very very old version of Debian)
* I will look at testing these steps properly when I get a chance and incorporating these instructions or updating them into the main guide available at https://wiki.koha-community.org/wiki/Koha_on_Debian
Comment 4 Katrin Fischer 2020-01-06 19:26:50 UTC
Hi Seema, 

you can try to restart Plack and Memcached to make sure that your changes to the configuration files have taken effect.

But this should be really discussed on the mailing list as it's a installation/setup issue and probably not a bug:

https://koha-community.org/support/koha-mailing-lists/

 It will also mean a lot more people are reading and will be able to help out - only very few of us are reading all the new bugs :)
Comment 5 Seema Albal 2020-01-07 05:21:16 UTC
(In reply to David Nind from comment #3)
> Hopefully this will point you in the right direction to solve the problem
> you are having:
> https://wiki.koha-community.org/wiki/Install_Koha_3.
> 6_on_Debian_squeeze_using_a_separate_MySQL_server
> 

This helped! Thanks
Comment 6 Seema Albal 2020-01-07 06:39:20 UTC
Just updating what actually worked...

Following the steps in the wiki page, I landed the "Sorry, this page is under maintenance ...." page. 
Looked around and found that using this method, I had to do koha-enable mylibrary

Upon doing that and restarting, (and still editing koha-conf.xml with right db host values), I got the same error again!! 

Then, as per @Katrin_Fischer, I did 

$service memcached restart (At this time browser setup gave maintenance page)
$koha-plack --enable mylibrary
$koha-plack --start mylibrary

This required some additional apache2 modules to be installed and restarted
(after this some 503 Service unavailable error)

And this did the trick!!

Thanks!
Comment 7 Seema Albal 2020-01-07 06:40:27 UTC
Thanks.. please ignore the 503 error in the above comment. Got the web installer running now!
Comment 8 David Nind 2020-01-07 06:59:06 UTC
Excellent! Glad to hear you got there!!