The MU forums have moved to WordPress.org

Mysql replace links (6 posts)

  1. enseignement
    Member
    Posted 15 years ago #

    Hello,

    Can someone help me to replace the default links in already registered members.
    Like a "search and replace" mysql request for wordpress.org etc. :-)

    I've searched in the forums but did not find anything for this...
    Benjamin

  2. tdjcbe
    Member
    Posted 15 years ago #

    To be honest, that's pretty basic (ok, maybe a little more than "basic.") server tech. Best bet would be to study the subject as there's a number of ways to do it.

    Link

  3. honewatson
    Member
    Posted 15 years ago #

  4. nologo1978
    Member
    Posted 14 years ago #

    This is an old post, but a ran across it trying to do the same thing as the person who posted this.

    I think it's pretty discouraging for people who ask a question, a pretty difficult question, and get some really elementary answers.

    Most people that are reading this are not going to be able to sit down and spend a week inserting an "update" search and replace for every field of every table.

    I used this to create a lab environment from a production database. Fill in the right global variables and the string that you want to find and replace down below. This actually should work for any search and replace for an entire database, whether wordpress or not.

    #!/usr/bin/perl
    
    use Mysql;
    
    # Global variables
    $host="localhost";
    $pass="xx";
    $user="xx";
    $db="xx";
    
    # Connect string
    $connect = Mysql->connect($host, $db, $user, $pass);
    $connect->selectdb($db);
    
    # Get tables
    $query = "show tables;";
    $execute = $connect->query($query);
    
    while (@results=$execute->fetchrow()) {
    	$fieldsq = "describe $results[0]";
    	$execdesc = $connect->query($fieldsq);
    	while (@fieldrslts = $execdesc->fetchrow()) {
    		$updateq = "update $results[0] set $fieldrslts[0] = replace \($fieldrslts[0],\'myblogg.blogg.se\',\'myblogglab.blogg.se\'\)";
    		$execupd = $connect->query($updateq);
    	};
    };
  5. cafespain
    Member
    Posted 14 years ago #

    Yeah, you didn't read the original post did you???

    He asked how to replace the default links for existing users.
    That's a single update SQL statement run on a MySql server - absolutely nothing to do with WPMU, which is probably why they received such answers.

  6. nologo1978
    Member
    Posted 14 years ago #

    My bad and my apologies. Nevertheless, I thought this was a bit of a pain in the ass but here's the code... take it or leave it.

About this Topic

  • Started 15 years ago by enseignement
  • Latest reply from nologo1978