PHPackages                             guigaba/search-replace-db - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. guigaba/search-replace-db

ActiveLibrary[Database &amp; ORM](/categories/database)

guigaba/search-replace-db
=========================

A PHP search replace tool for quickly modifying a string throughout a database. Useful for changing the base URL when migrating a WordPress site from development to production.

4(8y ago)063GPL-3.0PHPPHP &gt;=7

Since Mar 24Pushed 8y ago1 watchersCompare

[ Source](https://github.com/guigaba/Search-Replace-DB)[ Packagist](https://packagist.org/packages/guigaba/search-replace-db)[ Docs](https://github.com/guigaba/Search-Replace-DB)[ RSS](/packages/guigaba-search-replace-db/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)DependenciesVersions (7)Used By (0)

Search Replace DB
=================

[](#search-replace-db)

This script was made to aid the process of migrating PHP and MySQL based websites. It has additional features for WordPress and Drupal but works for most other similar CMSes.

If you find a problem let us know in the issues area and if you can improve the code then please fork the repository and send us a pull request :)

Warnings &amp; Limitations
--------------------------

[](#warnings--limitations)

1. Three character UTF8 seems to break in certain cases.
2. We can't test every possible case, though we do our best. Backups and verifications are important.
3. The license for this script is GPL v3 and no longer WTFPL. Please bear this in mind if contributing or branching.
4. You use this script at your own risk and we have no responsibility for any problems it may cause.
5. *Do backups.*

Usage
-----

[](#usage)

1. *Do backups.*
2. Migrate all your website files.
3. Upload the script folder to your web root or higher.
4. Browse to the script folder URL in your web browser.
5. Fill in the fields as needed.
6. Choose the `Dry run` button to do a dry run without searching/replacing.

Installation
------------

[](#installation)

If you would like Search Replace DB to detect your WordPress installation, you should install it within a new subfolder within your WordPress installation.

For example, if you have

```
/website.com/index.php

/website.com/wp-config.php

/website.com/wordpress/

/website.com/wordpress/index.php

/website.com/wordpress/wp-settings.php

etc.

```

You can copy Search Replace DB into the following location:

```
/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 script

[](#cli-script)

To invoke the script, nagivate in your shell to the directory to where you installed Search Replace DB.

Type `php srdb.cli.php` to run the program. Type `php srdb.cli.php --help` for usage information:

```
-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 ;)

```

Troubleshooting
---------------

[](#troubleshooting)

### I get a popup saying there was an AJAX error

[](#i-get-a-popup-saying-there-was-an-ajax-error)

This happens occasionally and could be for a couple of reasons:

- When the script starts, it attempts to start your WordPress or Drupal installation to auto-detect your username and password settings. If this fails, you will see a message informing you that auto-detection failed. You will have to enter your details manually.
- Script was unable to set the timeout so PHP closed the connection before the table could be processed, this can happen on some server configurations.
- When using php-fpm (as you have with VVV) make sure that the socket is owned by the server user `chown www-data:www-data /var/run/php5-fpm.sock`.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~501 days

Total

4

Last Release

2977d ago

Major Versions

3.1 → 4.0.x-dev2016-12-01

PHP version history (3 changes)3.0.0PHP &gt;=5.3.0

4.0.x-devPHP &gt;=5.6

4PHP &gt;=7

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4174320?v=4)[Guilherme Nascimento](/maintainers/guigaba)[@guigaba](https://github.com/guigaba)

---

Top Contributors

[![roborourke](https://avatars.githubusercontent.com/u/23417?v=4)](https://github.com/roborourke "roborourke (57 commits)")[![matt-icit](https://avatars.githubusercontent.com/u/11349605?v=4)](https://github.com/matt-icit "matt-icit (31 commits)")[![hyperionjrw](https://avatars.githubusercontent.com/u/273783?v=4)](https://github.com/hyperionjrw "hyperionjrw (10 commits)")[![tomjn](https://avatars.githubusercontent.com/u/58855?v=4)](https://github.com/tomjn "tomjn (7 commits)")[![rausanka](https://avatars.githubusercontent.com/u/215072?v=4)](https://github.com/rausanka "rausanka (6 commits)")[![davecoveney](https://avatars.githubusercontent.com/u/239414?v=4)](https://github.com/davecoveney "davecoveney (5 commits)")[![getdave](https://avatars.githubusercontent.com/u/444434?v=4)](https://github.com/getdave "getdave (5 commits)")[![msenateatplos](https://avatars.githubusercontent.com/u/1385738?v=4)](https://github.com/msenateatplos "msenateatplos (3 commits)")[![bsy-web](https://avatars.githubusercontent.com/u/4024514?v=4)](https://github.com/bsy-web "bsy-web (2 commits)")[![mamchenkov](https://avatars.githubusercontent.com/u/437928?v=4)](https://github.com/mamchenkov "mamchenkov (2 commits)")[![sheabunge](https://avatars.githubusercontent.com/u/1170783?v=4)](https://github.com/sheabunge "sheabunge (2 commits)")[![bananastalktome](https://avatars.githubusercontent.com/u/60870?v=4)](https://github.com/bananastalktome "bananastalktome (1 commits)")[![herewithme](https://avatars.githubusercontent.com/u/898608?v=4)](https://github.com/herewithme "herewithme (1 commits)")[![cyberhobo](https://avatars.githubusercontent.com/u/286838?v=4)](https://github.com/cyberhobo "cyberhobo (1 commits)")[![Rahe](https://avatars.githubusercontent.com/u/1007502?v=4)](https://github.com/Rahe "Rahe (1 commits)")[![tentwofour](https://avatars.githubusercontent.com/u/4117615?v=4)](https://github.com/tentwofour "tentwofour (1 commits)")

### Embed Badge

![Health badge](/badges/guigaba-search-replace-db/health.svg)

```
[![Health](https://phpackages.com/badges/guigaba-search-replace-db/health.svg)](https://phpackages.com/packages/guigaba-search-replace-db)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[pgvector/pgvector

pgvector support for PHP

198628.3k10](/packages/pgvector-pgvector)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
