Cannot connect to database

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
stans78
New user
New user
Posts: 9
Joined: 2009-03-27 20:14

Cannot connect to database

Post by stans78 » 2017-05-04 08:20

After a weekend malware attack & multiple virus scans*, I'm unable to log into the hMail admin console. This is the error message I get:

"The connection to the database is not available.
Host'localhost' is not allowed to connect to this MySQL server"

Attempts to send/receive email generate similar messages in the error log.

I'm using Windows Server 2008 R2, hMailSErver v5.6 standard installation with built-in MySQL DB. There's a stand-alone MySQL install on this server that's still running properly.

I've looked (and am still looking) for solutions but haven't found anything close enough to my particular problem. Any help getting reconnected would be appreciated--or do I need to reinstall hMailServer?

*Not sure if this has anything to do with my problem or not.
Windows Server 2008 R2
hMailServer v5.6 standard installation

User avatar
mattg
Moderator
Moderator
Posts: 20028
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Cannot connect to database

Post by mattg » 2017-05-04 11:23

Are you sure that your hMailserver uses a built in MySQL database?
hMailserver hasn't shipped with MySQL as the built in database for many years (since 2011).

Can you please post the contents of your hMailserver.ini without the passwords.
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

stans78
New user
New user
Posts: 9
Joined: 2009-03-27 20:14

Re: Cannot connect to database

Post by stans78 » 2017-05-04 19:44

Here it is (thanks for reply)...

Code: Select all

[Directories]
ProgramFolder=C:\Program Files (x86)\hMailServer
DataFolder=C:\Program Files (x86)\hMailServer\Data
LogFolder=C:\Program Files (x86)\hMailServer\Logs
TempFolder=C:\Program Files (x86)\hMailServer\Temp
EventFolder=C:\Program Files (x86)\hMailServer\Events
DatabaseFolder=C:\Program Files (x86)\hMailServer\Database
[GUILanguages]
ValidLanguages=english,swedish
[Database]
Internal=1
type=MYSQL
username=root
password=***
passwordencryption=1
port=3307
server=localhost
database=hMailServer
[Security]
AdministratorPassword=***
Been using hMailServer for many years, this is an upgrade from an earlier version.
Windows Server 2008 R2
hMailServer v5.6 standard installation

User avatar
mattg
Moderator
Moderator
Posts: 20028
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Cannot connect to database

Post by mattg » 2017-05-05 01:05

OK you definitely have MySQL as the built in

That was community edition of MySQL 4.X, and the only difference was where the database was stored (in the hMailserver database directory rather than MySQL directory) AND the port used (normally port 3306, in the builtin case 3307)

There should be database logs in the database folder.

ALSO, you can connect to the MySQL instance using MySQLd (just remember to change the port number to 3307)
http://stackoverflow.com/questions/1844 ... rver-after
https://dev.mysql.com/doc/refman/5.5/en ... blems.html

You could use MySQLd to dump the hMailserver database and restore to the main MYSQL database on that machine, just updating your hMailserver.ini accordingly - That's how I first moved from the internal MySQL to using the standalone MySQL
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

stans78
New user
New user
Posts: 9
Joined: 2009-03-27 20:14

Re: Cannot connect to database

Post by stans78 » 2017-05-05 08:06

I tried the suggestions at the links with no success. Whenever I try to access MySQL on port 3307, I get the 'localhost not allowed...' msg. It appears that the OP in the first link had the same result and was only able to 'solve' his problem by reinstalling software.

So it looks like I'll be upgrading to the latest version of hMailServer.
Windows Server 2008 R2
hMailServer v5.6 standard installation

User avatar
mattg
Moderator
Moderator
Posts: 20028
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Cannot connect to database

Post by mattg » 2017-05-05 08:27

Whilst that is a great idea, it won't help in this case as it won't reinstall the internal MySQL.

Have you tried connecting with the command line mySqlD??
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

stans78
New user
New user
Posts: 9
Joined: 2009-03-27 20:14

Re: Cannot connect to database

Post by stans78 » 2017-05-08 07:41

I was able to connect with mysqld, and found two users named root; one with host field = '%', the other, 'localhost'. Is this normal?
Windows Server 2008 R2
hMailServer v5.6 standard installation

User avatar
mattg
Moderator
Moderator
Posts: 20028
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Cannot connect to database

Post by mattg » 2017-05-09 00:57

I don't think so

All of my users have the host of 'localhost'
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

stans78
New user
New user
Posts: 9
Joined: 2009-03-27 20:14

Re: Cannot connect to database (solved)

Post by stans78 » 2017-05-09 20:12

Problem solved:
I had to repair the user table (table was erased by the repair) and then add root/localhost/password back into the table. Once I did this, I was able to log in to the hMailSErver admin program and the mail server itself resumed normal operation.
Thanks again for your help.
Windows Server 2008 R2
hMailServer v5.6 standard installation

Post Reply