Manual:SQLite/zh

从MediaWiki 1.17开始，对MediaWiki的SQLite支持具有生产质量. 自MediaWiki 1.13版以来，SQLite支持已成为主要代码库的一部分. 下面有一些关于将SQLite库安装到PHP环境中的注释.

关于SQLite
SQLite是一个发布到公共领域的开源数据库. 与客户端-服务器数据库管理系统不同，SQLite库是链入PHP的，因此成为不可或缺的一部分服务器进程. MediaWiki通过简单的函数调用使用SQLite的功能，这减少了数据库访问中的潜伏，因为函数调用比进程间通信更有效.

使用SQLite作为MediaWiki的数据库后端有其自身的优点和缺点：


 * 优点


 * 您不必安装和维护MySQL等独立数据库服务器，这大大减少了用于管理的工作并消除了一些失败点.
 * 前者也意味着SQLite更适合从USB记忆棒运行的便携式MediaWiki安装.
 * 您不受共享主机上的人为数据库限制的限制.
 * 整个数据库存储为单个跨平台文件，简化了备份和迁移.


 * 缺点


 * SQLite不具备可扩展性，所以如果你有一个大而流行的wiki，你应该使用MySQL.
 * 虽然SQLite有自己的搜索引擎，但Lucene等更先进的解决方案并不支持它.
 * 某些PHP版本（RHEL5及更旧版本、旧版本的XAMPP）附带过时的SQLite版本，这些版本限制了功能并可能包含错误.
 * 已知有几个扩展具有SQLite的数据库更新或安装问题：AbuseFilter、Echo、Flow和LiquidThreads.

安装SQLite
虽然由于，至少SQLite版本3.3.7是必需，但建议使用SQLite 3.6，因为它修复了一些数据完整性错误. 此外，为了使用全文搜索，必须在启用FTS3模块的情况下编译SQLite（大多数版本现在都开箱即用）. SQLite3通过PHP的PDO函数工作.

Anything outside of the webroot should be safe; it's good to keep it nearby. Or, if you feel like it, you could put it in the web root somewhere and make sure to use webserver config to deny access to it.
 * 要在基于Debian的系统上安装SQLite3，请使用.
 * 在较新的Ubuntu和可能的其他发行版上，该包被称为 （最后没有3个！），请小心.
 * 来自php.net的Windows二进制文件都可以.
 * 自PHP 5.1.0起，SQLite依赖于PDO. 您应该在 中取消注释以下两行 (note: sometimes you can't even use  to check if they are present, because an SQLite-enabled PHP tends to crash or fail when PDO is absent, especially on Windows):
 * (or  for Windows)
 * (or  for Windows)
 * Where should you put the SQLite database itself? The default path seems to be $IP/../data/$dbname.sqlite.

Installing MediaWiki on SQLite backend

 * If SQLite module for PHP is properly installed, MediaWiki installer should offer you an option to use SQLite. On MediaWiki versions prior to  1.16, you need to enter something into the "DB username" and "DB password" fields for installer to continue even though SQLite does not need them.
 * If you enter nothing into the "SQLite data directory" field, your will be left empty, which corresponds to   directory in the parent of the document root, however this directory might be different for web scripts and maintenance scripts run from command line, so specifying it explicitly is recommended.

Search engine
Search capabilities for SQLite backend was introduced in MediaWiki 1.16. They require SQLite with FTS3 module compiled-in, which is usually present in most modern builds. If you've recently updated your SQLite support to a version that includes FTS3, run the updater as if you're upgrading MediaWiki. After the updater script created the search index table, populate it with. Same applies to switches back to environments without FTS3: re-running the updater will downgrade the table to avoid SQL errors.

Unable to access the database on the terminal
To get command-line access to the database, type on the terminal:

sqlite3 /var/data/database_name.sqlite

replacing  with the directory that was set as the "SQLite data directory" during the installation process. Alternatively, look for inside.

This can be tricky if you are not experienced about SQLite and run  - because this will open a completely different database (creating it if it doesn't exist) since SQLite interprets the argument not as a system-wide database name, but instead as the file name that contains the db.

Problems
Bugs should be reported to Wikimedia's bug tracker. First check if your problem was already reported - check the dependencies of and use search. If you can't find your problem, create a new issue. If the problem is directly related to SQLite backend, report it under MediaWiki → Database component. Otherwise (if the problem is related to one very specific aspect, of the software or an extension), select an appropriate product and component. In any case please take some steps to make your bug easy to find and track: mention SQLite is its summary field and make it depend on bug 22257.

参见

 * SQLite-specific configuration settings:


 * 维护脚本

外部链接

 * Migrating Mediawiki from MySQL to SQLite
 * SQLite home page
 * Wikipedia article on SQLite