SQLite Forum

Setting Database file directory on linux

Setting Database file directory on linux

(1) By M.R.P. (zensky) on 2020-04-19 20:28:20 [source]

Hello I want to create a database and have my sqlite DB file to be written to a specific directory. How can I do this?

(2.2) By Larry Brasfield (LarryBrasfield) on 2020-04-19 21:37:05 edited from 2.1 in reply to 1 [link] [source]


  1. Install or otherwise obtain sqlite3 (as it is called in package repositories used by many Linux distros).

  2. Make sure its executable location can be found among the directories $PATH expands to.

  3. Start bash or other Bourne-shell inspired command-line-shell.

  4. Enter, without quotes, 'which sqlite3' , or equivalent for your system.

  5. If nothing shows up, repeat steps 2-5.

  6. Make sure the directory in which you want to have that "DB file .. written" is writable by you logged into an account you have access to. Let's call that directory ~/MyDbFiles (as an example.)

  7. Enter, without quotes, 'sqlite3 ~/MyDbFiles/myNewestDbFile.db' .

  8. Enter 'CREATE TABLE GetSqliteToMakeDB(id); DROP TABLE GetSqliteToMakeDB;'

  9. Enter, into the sqlite shell, without quotes, '.q' .

  10. Observe your new DB file, perhaps with 'file ~/MyDbFiles/myNewestDbFile.db' .

  11. If you want your DB file to have content, that's another task.