PHPackages                             interconnectit/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. interconnectit/search-replace-db

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

interconnectit/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.1.4(1y ago)4.1k113.8k—3.5%856[8 issues](https://github.com/interconnectit/Search-Replace-DB/issues)[9 PRs](https://github.com/interconnectit/Search-Replace-DB/pulls)7GPL-3.0PHPPHP &gt;=7.1CI failing

Since Mar 24Pushed 1y ago152 watchersCompare

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

READMEChangelog (7)Dependencies (1)Versions (9)Used By (7)

[![Build Status](https://camo.githubusercontent.com/5ab96ae07615ec6ca061d6a4dc85413e9cc7a81b9d090bde8767425dae5d7401/68747470733a2f2f7472617669732d63692e6f72672f696e746572636f6e6e65637469742f5365617263682d5265706c6163652d44422e7376673f6272616e63683d342e30)](https://travis-ci.org/interconnectit/Search-Replace-DB)

Search Replace DB - v4.1.4
==========================

[](#search-replace-db---v414)

This script was made to aid the process of migrating PHP and MySQL based websites. Works with most common 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 :)

What's New in 4.1.4
-------------------

[](#whats-new-in-414)

Adapted to work with a broader range of PHP versions - warnings in PHP 8.x versions should be gone now.

What's New in 4.1
-----------------

[](#whats-new-in-41)

- Support for continuous integration through Travis CI
- Ability to do multiple search-replaces
- Ability to exclude tables
- Remove specific loaders for WP
- No longer automatically populate DB fields, this was causing security issues for users leaving the script on their site
- Script now checks whether the correct version of PHP is used
- Script checks if necessary modules are installed
- Script checks if the connection is secure and gives a warning otherwise
- Bug fixes
- UI Tweaks
- Password is not mandatory in CLI
- Ability to connect using SSL, command line only feature

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

[](#warnings--limitations)

We can't test every possible case, though we do our best. Backups and verifications are important.

You use this script at your own risk and we have no responsibility for any problems it may cause.

There are many edge cases and WordPress plugins that likes to mess your database, we don't have a silver bullet.

The license for this software is GPL v3, please bear this in mind if contributing or branching.

*Do backups*, also *do backups* and finally *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 `Do a safe test run` button to do a dry run without searching/replacing.

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

[](#installation)

To install the script, please place the files inside your sites public folder and head to yoursiteURL/Search-Replace-DB

### CLI script

[](#cli-script)

To invoke the script, navigate 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
    Database user's password.

  -P, --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.

  -w, --exclude-tables
    If set excluded the specified tables, comma separate for multuple
    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 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.

  --debug [true|false]
    Defaults to false, prints more verbose errors.

  --ssl-key
    Define the path to the SSL KEY file.

  --ssl-cert
    Define the path to the SSL certificate file.

  --ssl-ca
    Define the path to the certificate authority file.

  --ssl-ca-dir
    Define the path to a directory that contains trusted SSL CA
    certificates in PEM format.

  --ssl-cipher
    Define the cipher to use for SSL.

  --ssl-check [true|false]
    Check the SSL certificate, default to True.

  --allow-old-php [true|false]
    Suppress the check for PHP version, use it at your own risk!

  --help
    Displays this help message ;)

```

### Example cli commmands:

[](#example-cli-commmands)

```
php srdb.cli.php -h dbhost -n dbname -u root -p "" -s "http://www.yourdomain.com" -r "http://newdomain.com"

php srdb.cli.php -h dbhost -n dbname -u root -p "password" -s "http://www.yourdomain.com" -r "http://newdomain.com"

php srdb.cli.php -h dbhost -n dbname -u root -p "password" -s "search" -r "replace"
```

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

[](#troubleshooting)

### Nothing works after the search/replace operation!

[](#nothing-works-after-the-searchreplace-operation)

It's time to use your backups!

### 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.

Contributing
------------

[](#contributing)

You can view the source code and submit a pull request using GitHub, the project's page is located at:

We appreciate a small unittest among the code, please explain what you are is trying to solve.

License
=======

[](#license)

This file is part of Search-Replace-DB.

Search-Replace-DB is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

Search-Replace-DB is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Search-Replace-DB. If not, see .

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance45

Moderate activity, may be stable

Popularity63

Solid adoption and visibility

Community46

Growing community involvement

Maturity63

Established project with proven stability

 Bus Factor3

3 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 ~666 days

Recently: every ~449 days

Total

7

Last Release

440d ago

Major Versions

3.1 → 4.02020-03-31

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

4.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/77dbeefb7745010589603f2ffc6ff310d8f700b58e08d52af190744c43342526?d=identicon)[roborourke](/maintainers/roborourke)

---

Top Contributors

[![gianluigi-icit](https://avatars.githubusercontent.com/u/30470221?v=4)](https://github.com/gianluigi-icit "gianluigi-icit (78 commits)")[![jack-interconnectit](https://avatars.githubusercontent.com/u/42768516?v=4)](https://github.com/jack-interconnectit "jack-interconnectit (62 commits)")[![zanzix](https://avatars.githubusercontent.com/u/10865933?v=4)](https://github.com/zanzix "zanzix (60 commits)")[![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)")[![interconnectitalfie](https://avatars.githubusercontent.com/u/155558730?v=4)](https://github.com/interconnectitalfie "interconnectitalfie (11 commits)")[![hyperionjrw](https://avatars.githubusercontent.com/u/273783?v=4)](https://github.com/hyperionjrw "hyperionjrw (10 commits)")[![davecoveney](https://avatars.githubusercontent.com/u/239414?v=4)](https://github.com/davecoveney "davecoveney (9 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)")[![fauria](https://avatars.githubusercontent.com/u/742022?v=4)](https://github.com/fauria "fauria (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)")[![pcurrier](https://avatars.githubusercontent.com/u/684097?v=4)](https://github.com/pcurrier "pcurrier (2 commits)")[![macbookandrew](https://avatars.githubusercontent.com/u/784333?v=4)](https://github.com/macbookandrew "macbookandrew (2 commits)")[![jnorell](https://avatars.githubusercontent.com/u/751040?v=4)](https://github.com/jnorell "jnorell (2 commits)")[![sheabunge](https://avatars.githubusercontent.com/u/1170783?v=4)](https://github.com/sheabunge "sheabunge (2 commits)")[![colinfoster](https://avatars.githubusercontent.com/u/491234?v=4)](https://github.com/colinfoster "colinfoster (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90440.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)[wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

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