CLI export credentials

Describe the problem/error/question

I am unable to export credentials using CLI command.

Does it works using MySQL database configuration ?

What is the error message (if any)?

Error exporting credentials. See log messages for details.
No credentials found with specified filters.

Any ideas ?

Could we export table credentials_entity and use it with other n8n versions for example ?

Information on your n8n setup

  • n8n version:0.216.3
  • Database (default: SQLite): MySQL
  • Running n8n via npm
  • Operating system:linux

Hey @fmarrot,

Are you running the command as the same user running n8n?

Hi @Jon yes I do, user is the same.

Hey @fmarrot,

That is a bit unusual normally that is all you need to do, Can you try running it from that users home directory if you are not already?

Hi @Jon, I can confirm we are running command as the same user running n8n in user home directory.

What could you suggest ?

Thanks

Hey @fmarrot,

I don’t really have anything else, I have given it a go here on a couple of installs and it worked. Can you try exporting the workflows and see if that works?

Can you also share your n8n configuration and how you are launching it?

Hi @Jon thanks for your answer.

As you suggested I tried to export workflow unfortunately with the same result, not working.

Error exporting credentials. See log messages for details.
No credentials found with specified filters.

We launch n8n service with /opt/n8n/app/node_modules/n8n/bin/n8n

Our n8n config (confidential settings replaced with xxxx)

[root@n8n ~]# cat /opt/n8n/etc/n8n.json
{
    "database": {
        "mysqldb": {
            "database": "n8n",
            "host": "db.xxxx.net",
            "password": "xxxx",
            "port": 3306,
            "user": "n8n"
        },
        "type": "mysqldb"
    },
    "generic": {
        "timezone": "Europe/Paris"
    },
    "port": 8021
}

Our environnement variables (confidential settings replaced with xxxx)

[root@n8n ~]# cat /opt/n8n/etc/env
N8N_CONFIG_FILES=/opt/n8n/etc/n8n.json
N8N_USER_FOLDER=/opt/n8n/data
WEBHOOK_TUNNEL_URL=https://workflow.xxxx.net/
VUE_APP_URL_BASE_API=https://workflow.xxxx.net/
N8N_ENCRYPTION_KEY='xxxx'
EXECUTIONS_DATA_PRUNE=true
EXECUTIONS_DATA_MAX_AGE=360
N8N_CUSTOM_EXTENSIONS=/opt/n8n/.n8n/custom
NODE_FUNCTION_ALLOW_BUILTIN=request-promise-native
N8N_PAYLOAD_SIZE_MAX=64
N8N_USE_DEPRECATED_REQUEST_LIB=True
NODE_FUNCTION_ALLOW_EXTERNAL=axios

Do you think that we can maybe export from our N8N MySQL database credentials_entity table and then import it later easily to another n8n version ? It will work ?

Hey @fmarrot,

You could export the table and import it as long as you have the encryption key, I am not sure why the command is failing though ti should be working.

Are you running n8n as root?

n8n is running with user called n8n, so is not running as root.

I have a feeling the issue could be N8N_USER_FOLDER=/opt/n8n/data. Let me take a quick look at the CLI and see if that option is taken into consideration.

Had a quick look and it looks like it should be picking that up, In /opt/n8n/data/ is there a .n8n folder

@Jon yes it contains the following

image

I will free up some time to do some more testing and use your environment options to mimic your setup. It might sound odd but have you tried running the same command using the Execute Command node from inside n8n?

@Jon thanks for your time !

Yeah it was our inital goal, save in gitea all our workflow as well as credentials.

We use gitea API combined with N8N API to store all we need in gitea and it works pretty well, except for credentials, N8N api doesn’t allow to export it.

So we look after n8n cli commands to that.

Here the screenshots (command failed)

with npx

Don’t waste your time, as you said before “You could export the table and import it as long as you have the encryption key, I am not sure why the command is failing though ti should be working.”

N8N_ENCRYPTION_KEY is the correct parameter ?

I think when N8N v1 will be available we’ll use it as a fresh install with PostgreSQL.

Yeah N8N_ENCRYPTION_KEY is the important one.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.