username & password in sqlite3

后端 未结 4 587
再見小時候
再見小時候 2021-01-01 11:17

I am using sqlite3 in a linux machine and I am getting the database without username and password. Can I set a username and password for the same?

相关标签:
4条回答
  • 2021-01-01 12:08

    SQLite doesn't have a concept of username/password. It's just a single file based database.

    However, on Unix you can protect your database from other users on the same machine by setting the permissions of the database file itself.

    e.g. Allow only owner access

    chmod 700 /path/to/sqlitedb

    If it's used in a simple web application then the web application will provide the control.

    0 讨论(0)
  • 2021-01-01 12:11

    The prior answers are only partially true. You can have databases that require authentication but you'll have to compile SQLite separately from PHP.

    See the SQLite User Authentication documentation for further information.

    0 讨论(0)
  • 2021-01-01 12:18

    No, sqlite3 databases are very lightweight systems. They need no server and all data is stored in one file. A username/password is not supported by the sqlite/sqlite3 package.

    In order to achieve simplicity, SQLite has had to sacrifice other characteristics that some people find useful, such as high concurrency, fine-grained access control, a rich set of built-in functions, stored procedures, esoteric SQL language features, XML and/or Java extensions, tera- or peta-byte scalability, and so forth.

    (sqlite, when to use)

    However, since it's only a file you can encrypt the file with a password to protect your data.

    0 讨论(0)
  • 2021-01-01 12:19

    SQLite is mainly an embedded database engine, not intended to be used as a multi-user database server that would require usernames and passwords.

    You can always encrypt the database file with some user-provided password/-phrase, I guess. But expecting an embedded DBMS to sport full-blown access control is too much.

    0 讨论(0)
提交回复
热议问题