Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to database is denied with MariaDB #2493

Closed
binalloy opened this issue Aug 16, 2019 · 11 comments
Closed

Access to database is denied with MariaDB #2493

binalloy opened this issue Aug 16, 2019 · 11 comments

Comments

@binalloy
Copy link

I am trying to run FreshRSS with MariaDB 10 on my NAS. Everything was fine while the installation until I tried to log in. I got the following error:

### Application problem ###
See logs files

and the content in /data/users/username/log.txt

Access to database is denied for `freshrss` (`mysql:host=localhost;dbname=freshrss;charset=utf8mb4;port=3307`)

I run the script given in #1243 (comment), and get the following:

PHP version:	7.0.33
MySQL version:	5.5.5-10.3.7-MariaDB
Array
(
    [0] => Array
        (
            [VERSION()] => 10.3.7-MariaDB
        )

)
Array
(
    [0] => Array
        (
            [cs] => utf8
        )

    [1] => Array
        (
            [cs] => utf8mb4
        )

    [2] => Array
        (
            [cs] => utf16
        )

    [3] => Array
        (
            [cs] => utf16le
        )

    [4] => Array
        (
            [cs] => utf32
        )

)
Array
(
    [0] => Array
        (
            [id] => 1
            [name] => Uncategorized
        )

)

The connection to the database seems fine. I can't figure out what's wrong.

@Alkarex
Copy link
Member

Alkarex commented Aug 17, 2019

Hello,
Hum, I cannot immediately think of what the problem could be.
I have just tested with MariaDB 10.4.7-bionic from https://hub.docker.com/_/mariadb and it seems to work fine.
Do you have a command line to the database? If yes, could you check:

SHOW grants;

@Alkarex
Copy link
Member

Alkarex commented Aug 17, 2019

You could also try with SQLite, PostgreSQL, or MySQL

@binalloy
Copy link
Author

I found that my default setting of MariaDB 10 package is not the same as usual, which is port: 3307, socket: /run/mysqld/mysqld10.sock, and that made the trouble. When I tried to log in the database in the command line using localhost and port, I got prompt Can't connect to local MySQL server through socket. But I could successfully log in with 127.0.0.1 and port. Later after google, I realized that the connection to the database will go through socket when you specify the hostname as localhost while through the TCP when specify as 127.0.0.1.

So there are two options for my case.

  • use 127.0.0.1 as hostname
  • change the pdo_mysql.default_socket to /run/mysqld/mysqld10.sock in the PHP configuration.

I tried both and both of them works fine.

The tricky thing is that during the installation, the hostname localhost:3307 seemed to be solved to 127.0.0.1:3307 before the connection so that the installation was fine, but not after the installation completed.

Anyway, thanks for your hint!

@Alkarex
Copy link
Member

Alkarex commented Aug 18, 2019

Thanks for the feedback @binalloy
I cannot immediately think of what could explain a resolution difference during install and after it. That would require a bit more investigation. In any case, we should try to use the main code during the install process to reduce differences.

@gpion
Copy link

gpion commented Oct 12, 2019

  • use 127.0.0.1 as hostname

Thanks for the tip!
I was facing the same issue on my NAS after a recent package update (not sure if its was PHP or MariaDB).
Anyway I'm really confused that using "127.0.0.1" instead of "localhost" can make any difference. Nut the fact is that it did!

@Alkarex
Copy link
Member

Alkarex commented Oct 12, 2019

This happens when either IPv4 or IPv6 is not correctly set up, or when the database is not listening on IPv4 or IPv6. Everything defaults more and more to IPv6, but there are sometimes elements that are lagging behind.
For the record, the install procedure has been reworked to use the same code than when using FreshRSS #2522

@gpion
Copy link

gpion commented Oct 12, 2019

This happens when either IPv4 or IPv6 is not correctly set up,

I'm using very basic default setup on my NAS regarding network, so I would be surprised this could be the root cause

or when the database is not listening on IPv4 or IPv6. Everything defaults more and more to IPv6, but there are sometimes elements that are lagging behind.

Looks like, on my NAS, MariaDB is only listening on IPv4, that could be the explanation:

root@fserv:/var/services/web > netstat -tlnp | grep mysql
tcp        0      0 0.0.0.0:3307            0.0.0.0:*               LISTEN      13987/mysqld        

For the record, the install procedure has been reworked to use the same code than when using FreshRSS #2522

I not sure if reinstalling from scratch would be a good idea for me.
Anyway, as long as it is fixed after having edited config.php with setting '127.0.0.1:3307' for $config['db']['host'] I'm fine.

@Alkarex
Copy link
Member

Alkarex commented Oct 12, 2019

No need to reinstall @gpion , the new code would only catch the problem earlier.

@gpion
Copy link

gpion commented Oct 12, 2019

No need to reinstall @gpion , the new code would only catch the problem earlier.

No need to reinstall to use the "reworked install procedure" ? Sorry I dont understand.

@Alkarex
Copy link
Member

Alkarex commented Oct 12, 2019

I just meant that if your current deployment works, you can just keep it as it is :-)

@gpion
Copy link

gpion commented Oct 12, 2019

Anyway, I've just found why MariaDB was only listening on IPv4 and not IPv6
I still had Mariadb5 installed (but not running) and it's my.cnf was symlinked in the default place ("/etc/my.cnf") overriding Mariadb10 defaults.
Specifically the "bind-address" setting of the "[mysqld]" section was explicitly set to "0.0.0.0" instead of "*".
After having uninstalled version 5 of MariaDB and restarted vesion 10, the daemon now listens on IPV6 socket as you can see:

$ > netstat -tlnp | grep mysql
tcp6       0      0 :::3307                 :::*                    LISTEN      9576/mysqld         

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants