qobo / search-replace-db
此包已被废弃且不再维护。没有建议的替代包。
interconnectit/search-replace-db 的分支!一个用于快速在数据库中修改字符串的 PHP 搜索替换工具。在将 WordPress 站点从开发迁移到生产时,更改基础 URL 时非常有用。
v4.0.2
2019-02-18 13:24 UTC
Requires
- php: >=5.3.0
Conflicts
This package is auto-updated.
Last update: 2023-04-19 06:47:11 UTC
README
此脚本旨在协助迁移基于 PHP 和 MySQL 的网站的过程。它为 WordPress 和 Drupal 提供了额外功能,但适用于大多数其他类似的 CMS。
如果您发现任何问题,请在问题区域告诉我们,如果您能改进代码,请分支存储库并发送给我们拉取请求:)
警告 & 限制
- 此包是 分支 自 interconnectit/Search-Replace-DB!请首先尝试使用上游原始版本。
- 在某些情况下,三个字符的 UTF8 似乎会出错。
- 尽管我们尽力测试,但我们无法测试所有可能的情况。备份和验证非常重要。
- 此脚本的许可证是 GPL v3,不再是 WTFPL。在贡献或分支时请记住这一点。
- 您使用此脚本自行承担风险,我们不承担因使用此脚本可能引起的问题的责任。
- 进行备份。
使用方法
- 进行备份。
- 迁移所有网站文件。
- 将脚本文件夹上传到您的网站根目录或更高位置。
- 在您的网页浏览器中浏览到脚本文件夹的 URL。
- 根据需要填写字段。
- 选择
Dry run
按钮以执行不带搜索/替换的测试运行。
安装
如果您希望 Search Replace DB 识别您的 WordPress 安装,您应该在您的 WordPress 安装内的一个新子文件夹中安装它。
例如,如果您有
/website.com/index.php
/website.com/wp-config.php
/website.com/wordpress/
/website.com/wordpress/index.php
/website.com/wordpress/wp-settings.php
etc.
您可以将 Search Replace DB 复制到以下位置
/website.com/wordpress/Search-Replace-DB/
/website.com/wordpress/Search-Replace-DB/index.php
/website.com/wordpress/Search-Replace-DB/srdb.class.php
/website.com/wordpress/Search-Replace-DB/srdb.cli.php
etc.
CLI 脚本
要调用脚本,请在您的 shell 中导航到您安装 Search Replace DB 的目录。
输入 php srdb.cli.php
来运行程序。输入 php srdb.cli.php --help
以获取使用信息
-h, --host
Required. The hostname of the database server.
-n, --name
Required. Database name.
-u, --user
Required. Database user.
-p, --pass
Required. Database user's password.
--port
Optional. Port on database server to connect to.
The default is 3306. (MySQL default port).
-s, --search
String to search for or `preg_replace()` style regular
expression.
-r, --replace
None empty string to replace search with or
`preg_replace()` style replacement.
-t, --tables
If set only runs the script on the specified table, comma
separate for multiple values.
-i, --include-cols
If set only runs the script on the specified columns, comma
separate for multiple values.
-x, --exclude-cols
If set excludes the specified columns, comma separate for
multiple values.
-g, --regex [no value]
Treats value for -s or --search as a regular expression and
-r or --replace as a regular expression replacement.
-l, --pagesize
How many rows to fetch at a time from a table.
-z, --dry-run [no value]
Prevents any updates happening so you can preview the number
of changes to be made
-e, --alter-engine
Changes the database table to the specified database engine
eg. InnoDB or MyISAM. If specified search/replace arguments
are ignored. They will not be run simultaneously.
-a, --alter-collation
Changes the database table to the specified collation
eg. utf8_unicode_ci. If specified search/replace arguments
are ignored. They will not be run simultaneously.
-v, --verbose [true|false]
Defaults to true, can be set to false to run script silently.
--help
Displays this help message ;)
故障排除
我收到一个弹出窗口,说有 AJAX 错误
这偶尔会发生,可能有几个原因
- 当脚本开始时,它尝试启动您的 WordPress 或 Drupal 安装以自动检测您的用户名和密码设置。如果失败,您将看到一条消息通知您自动检测失败。您将需要手动输入详细信息。
- 脚本无法设置超时,因此 PHP 在表处理之前关闭了连接,这在某些服务器配置中可能会发生。
- 当使用 php-fpm(如您在 VVV 中使用的那样)时,请确保套接字属于服务器用户
chown www-data:www-data /var/run/php5-fpm.sock
。