Remote Database Setup

Its pretty clear that the installation does not know where the MySQL is or its not installed

Before anything make sure you have everything setup as per #Post 6 if your install is a remote db based one if its a regular install, please follow instructions on EPRNext wiki

Hey @saidsl, already used these commands but still getting error.

@Saditi
Unless you install mysql or do a complete install you are not going to get much further. As I mentioned, your MySQL DB is not installed. Be it locally or remotely.

So please check that you have the right setup before progressing further

Hello @saidsl,

Changes in instance server:
common_site_config.json

Changes in database server:
Mysql changes :

This is my my.cnf file :

Error while creating new site:

I can’t connect to the mariadb on other server:

ERROR 2002 (HY000): Can't connect to MySQL server on '10.10.128.209' (115)
  • Should I open any port on the ERPNext server or Mariadb server?
  • Is there any difference between connect using public or private IP?
  • In the db server should I install bench too? Or is it able only MariaDB?
  • Do I need to connect to certain database (of a site) or can it connect to mysql?

Thank you for any help.

Setup the remote DB to accept remote connections :

in /etc/mysql/my.cnf or /etc/my.cnf

comment out:
bind-address=0.0.0.0

bench mariadb

mysql -uuser -ppass

GRANT ALL PRIVILEGES ON . TO user@% IDENTIFIED BY ‘pass’ WITH GRANT OPTION;

only for specific user and database (example):

GRANT ALL PRIVILEGES ON [Database_Name].* TO *[User_Name]*@% IDENTIFIED BY ‘[Password]’ WITH GRANT OPTION;

Restart remote MySQL

sudo service mysql restart

1 Like

Hi @Ernesto,
Sorry for not responding for too long.

There is no bind-address in my.cnf
but there is in /etc/my.cnf.d/mariadb-server.cnf and it’s already commented out.

It connects to a database [_xxxxxx].
Should it be to the root as it is for multi tenants.

Get a syntax error.

Hi Said, Do you have a clue about using the Azure Remote Database for Mariadb ?

Apparently the above steps won’t work with that (works perfectly with the rest).

Hi @Shinzuco - Unfortunately, I have not worked with Azure Remote DB. The setup outlined was meant for Linux based server setups.

However, It should not be any different to other setups in that, if you can access the DB externally than you would be able to connect to it.

You might want to look at the privileges/permissions on your Azure DB and whether external connections are permitted. I know some require tokens etc.

Regards - Said

It’s fairly easy to set up , the problem with Azure Remote DB is it accepts username in a “username@hostname” format and this conflicts with frappe’s code which uses “username” to create new db’s manage access etc.

@Shinzuco
I had also faced the same issue when I was trying to use RDS MariaDB and I resolved using just change the username in RDS MariaDB.

Yeah, it works for amazon since the username expected is in “username” format. Azure requires it to be sent in username@hostname format in the connection string and this cannot be changed from azure’s side afaik. We might need to customize database.py

If I am hosted by Erpnext.com can I Remote Database?

Thank you for your help!

I have App server as follows 192.168.1.26 and Mariadb DB server as follows 192.168.1.25 separately installed. Below is the App Server config…

App_server_con1

Above contains common_site_config.json
Ive added through bench set-mariadb-host 192.168.1.25

App_server_con2
this contains site_config.json on the app server.

For the DB server config pls refer to below :


this instance contains DB server 192.168.1.25 having mariadb. and config as above.

when i try to take the site backup by following command:

Its giving the below error as
Backup failed for site demo1.in. Database or site_config.json may be corrupted.

For the Database to access it from App server given permission required.
But somehow its creating Database in DB server but couldn’t able to take the backup.
Please help me on this…Thanks in Advance

You may have missed --no-mariadb-socket while creating new site. If you use that then it’ll create db user with wildcard host.

Refer this to fix it https://github.com/frappe/frappe_docker/blob/main/docs/troubleshoot.md#fixing-mariadb-issues-after-rebuilding-the-container

3 Likes

Tried, but the issue still persists…Please suggest.
Thanks in Advance

drop the user with ip as host, just keep the user with wildcard host.

2 Likes