Coder Social home page Coder Social logo

digideskio / search-replace-db Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amygdala/search-replace-db

0.0 1.0 0.0 444 KB

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.

PHP 100.00%

search-replace-db's Introduction

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 :)

Usage

  1. Migrate all your website files
  2. Upload the script folder to your web root or higher (eg. the same folder as wp-config.php or wp-content)
  3. Browse to the script folder URL in your web browser
  4. Fill in the fields as needed
  5. Choose the Dry run button to do a dry run without searching/replacing

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. Do backups.

CLI script

ARGS
	-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.
	-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 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 ;)

search-replace-db's People

Contributors

roborourke avatar tomjn avatar davecoveney avatar msenateatplos avatar bsy-web avatar herewithme avatar amygdala avatar cyberhobo avatar rahe avatar sheabunge avatar bananastalktome avatar tentwofour avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.