Search code examples
sqlbashmonetdb

monetdb: switch off password on mclient


I'd like to access monetdb database without password verification. I need this to put code into bash script and automatize some queries.

Command

mclient -u monetdb -d database

asks for password, which I'd like to omit (by default password is 'monetdb'). After this command I'd like to enter the database.

If it's not feasible, maybe there is a chance to pass the password (even with direct and visible text in code).


Solution

  • You can create a configuration file that contains your username and password.

    Before mclient starts parsing command line options, it reads a .monetdb file. If the environment variable DOTMONETDBFILE is set, it reads the file pointed to by that variable instead. When unset, mclient searches for a .monetdb file in the current working directory, and if that doesn’t exist, in the current user’s home directory. This file can contain defaults for the flags user, password, language, save_history, format, and width. For example, an entry in a .monetdb file that sets the default language for mclient to mal looks like this: language=mal. To disable reading the .monetdb file, set the variable DOTMONETDBFILE to the empty string in the environment.

    Put this into your .monetdb file and you won't have to manually enter your username and password.

    user=monetdb
    password=monetdb