New to Grafana installed Sqlite as a database source, added a file and get ... permission denied

Hi ,

I am the owner of the database file.
I am running Linux Kubuntu 21.04

In settings path I added /media/gb/DATA/Files/Data/Temporary/Database/TEST.db

Click on save and test and get
error checking db: error checking path: stat /media/gb/DATA/Files/Data/Temporary/Database/TEST.db: permission denied.

It was mentioned on the Sqlite add in to do this …
add the following lines ( which I did )
[Service]
ProtectHome=false

I hope you can help as i think Grafana will be good for me, but to fail so early is not good.

Thanks Gaz

did you check your file permission ? with the grafana user ?

Hi,

Not sure ?

I am running Grafana locally on my PC and login from my PC.
So does that make me the Grafana user

I have checked the file permission and I have full read and write permissions.

Thanks Gaz

No i mean user running your grafana service on your linux system.
does this account have permission on the file ?

1 Like

Hi again,

This is how I start Grafana from terminal … sudo /bin/systemctl start grafana-server
Otherwise I cannot start Grafana.

So root starts it , but I login with my user name and password that i selected when i first started Grafana a few days ago.

I have tried changing my database file to root, but still did not open.

Thanks

Gaz

Not sure if this helps but i have just added TestData DB from the grafana add database source and that does not give me any permissions errors.

@gazbaz You may want to try this on your Linux box:

ps -ef | grep grafana-server

You should see something like this:

grafana      976       1  0 14:03 ?        00:00:06 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini...
grafana     4851     976  0 14:04 ?        00:00:01 /var/lib/grafana/plugins/grafana-image-renderer/plugin_start_linux_amd64

So this shows that the server is running as the grafana user. Any file that process needs to allow reads to grafana.

One thing I do when trying to track down problems like this goes like this:

sudo -u grafana cksum /media/gb/DATA/Files/Data/Temporary/Database/TEST.db

cksum will just read through the entire file, doing a checksum. If that command gives you a “permission denied” you’ll know that the grafana-server process can’t read it either.

There’s a lot of backtracing to do to fix the permissions. I think I would do this:

sudo -u grafana bash

That way I’d have a bash shell that is running as the grafana user. Then I would try listing everything at each level of your absolute path to make sure I could read the files at that level, something like this:

ls -l /media
ls -l /media/gb
ls -l /media/gb/DATA
blah blah blah

Don’t worry – you’ll find it!

1 Like

Hi,

I am not very good with understanding the terminal output, but I did what you said and got

grafana@Mini-ITX-J5040:/home/gb$ ls -l /media
total 12
drwxr-x—+ 6 root root 4096 Jul 9 2021 Files
drwxr-x—+ 5 root root 4096 Aug 16 12:34 gb
drwxr-x—+ 2 root root 4096 Jul 8 10:23 root
grafana@Mini-ITX-J5040:/home/gb$ ls -l /media/gb
ls: cannot open directory ‘/media/gb’: Permission denied

Not sure what this all means :flushed:

Gotcha, no problem. You see the line where it shows gb says drwxr-x--- and then root root. What that means is that it’s a directory (d), it’s owned by user root in the group root, and that the user root has read-write-execute (rwx) and others in the group root have read-execute (r-x). (For a directory, x means you can “enter” the directory.)

Because you are grafana, you cannot enter that directory or read anything in it. I would recommend something like this (if it’s okay for every account to be able to enter that gb directory):

chmod o+rx /media/gb

That should change the permissions on that directory so that every user can see and enter it.

There’s a good amount to know about Linux file permissions, here’s a basic article about it:

Happy hunting!

1 Like

Hi, Thanks for that, I will need sometime to understand that, but I will :grinning:

Time for a break from my PC and come back later to read it all … ha ha

Thanks again

Hi again,

Thanks for your help, I can now access that database :grinning: :+1:

1 Like

Hey,I’ve got same issue. :confused:

I’ve done the checksum with no issues but Grafana still gives me the permission denied code. Any other options I can check?

Thank you

Is there any update on that topic?
The checksum works with no issues, I changed the permissions to rwx, did the official bug fix (ProtectHome=false) and it still doesn’t work :frowning:
I changed the path in Grafana:
/home: “error checking db: the provided path is a directory instead of a file”
/home/pi: “error checking db: error checking path: stat /home/pi: permission denied”
Not sure, if thats a hint where the permission is exactly denied…