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

How can we use external mySQL database with this script? #77

Open
krytie75 opened this issue Apr 2, 2022 · 8 comments
Open

How can we use external mySQL database with this script? #77

krytie75 opened this issue Apr 2, 2022 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@krytie75
Copy link

krytie75 commented Apr 2, 2022

As the title says really.

I'd like to use an already existant mySQL db, as per this method in the official docker version. How can I edit your script to allow this?

Edit: I'm trying to run npm directly in an LXC container, no Proxmox in my setup.

@manuelkamp
Copy link

bump - I want this too

@YakkaDev
Copy link

YakkaDev commented Apr 12, 2023

First method

You need to create /app/config/default.json file and put here next enviropments:

cfg: {
database: {
   'engine': 'mysql',
   'host': 'Host',
   'port': 'PORT',
   'user': 'envMysqlUser',
   'password': 'PASSWORD',
   'name': 'dbName'
 }
}

Then you must to rebuild frontend with yarn or npm (up to you) and reload nginx or reboot container.


Second Method

Also, you can edit /app/config/production.json and replace old vars to this vars.
Then you must to rebuild frontend with yarn or npm (up to you) and reload nginx or reboot container.


Third Method

Also, you can edit /app/lib/config.js and update following lines:

        const envMysqlHost = process.env.DB_MYSQL_HOST || 'HERE HOST';
        const envMysqlUser = process.env.DB_MYSQL_USER || 'HERE USER DB';
        const envMysqlName = process.env.DB_MYSQL_NAME || 'HERE NAME DB';
        if (envMysqlHost && envMysqlUser && envMysqlName) {
                // we have enough mysql creds to go with mysql
                logger.info('Using MySQL configuration');
                instance = {
                        database: {
                                engine:   'mysql',
                                host:     envMysqlHost,
                                port:     process.env.DB_MYSQL_PORT || HERE PORT,
                                user:     envMysqlUser,
                                password: process.env.DB_MYSQL_PASSWORD || 'HERE PASS',
                                name:     envMysqlName,
                        },

Then you must to rebuild frontend with yarn or npm (up to you) and reload nginx or reboot container.


Fourth method

You can use terminal command:

bash
export NODE_ENV='{"config": {"host":"fqdn/ip db", "port":"portdb", "user":"userdb", "name":"namedb", "password":"passdb",}}'

Then you must to rebuild frontend with yarn or npm (up to you) and reload nginx or reboot container.


P.S,
sorry for nekroposting, but mb this helps somebody.

Closed?

@cdonahue55
Copy link

None of these methods appear to work.

@mobilandi
Copy link

Hi @YakkaDev ,

thanks for your great answer! I'm pretty sure all those methods could work.
But I have to be honest, I have no clue how to rebuild frontend with yarn or npm:D
Could you or anyone give me a hint?

@ej52 ej52 self-assigned this Dec 4, 2023
@ej52 ej52 added the enhancement New feature or request label Dec 4, 2023
@ej52
Copy link
Owner

ej52 commented Dec 5, 2023

@YakkaDev Thanks for the detailed answer, I will look at incorporating this into the install script.

@ketomagasaki
Copy link

Hello @YakkaDev ,

I tried method 2:

Firstly, I retrieved the SQLite3 database located at /data/database.sqlite then converted it to .sql format and added it to my cluster.

Next, I modified the /app/config/production.json file

I restarted the service, restarted the container. But no change, NPM doesn't pick up the changes from this file. Additionally, there's a README.md in the /app/config/ directory that states the files in this folder are not considered if we are not in development mode.

I'm looking for another solution...

@ketomagasaki
Copy link

I have now tested method 3. This method works for connecting to an external database.

Unfortunately, the conversion I made from SQLite3 to SQL did not work well, and I encountered a lot of errors. I tried to find the nominal structure in the source GitHub repository: https://github.com/NginxProxyManager/nginx-proxy-manager, but I couldn't find a .sql file to install a proper base for MySQL / MariaDB. Do you know if this file exists?

Thank you

@ketomagasaki
Copy link

ketomagasaki commented Dec 21, 2023

So,

I installed the docker version with MariaDB of NPM by opening port 3306 on the database part. I made a dump of the initial database to create a template. I changed the engine to INNODB because I am on a Galera Cluster (doesn't work with ARIA).

And I imported this template into my cluster.

Now it works. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants