username & password in sqlite3

為{幸葍}努か 提交于 2019-11-30 00:36:35

问题


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?


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/1807320/username-password-in-sqlite3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!