Are you looking for a PHP script that can reset the WordPress Address (URL) of your blog? or Did you accidentally change the settings of the Blog Address (URL) from General settings then you were not able to access your blog because of this modification that you made?

Wordpress Adress URL

Now to solve my problem, I have prepared a PHP script to reset it to my original blog settings. Here’s the PHP script for the WordPress address URL reset that I used:

$dbhost = ‘localhost’;
$dbuser = ‘user_name’;
$dbpass = ‘password‘;
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die(’Error connecting to mysql’);
$dbname = ‘databasename’;
$query  = “UPDATE wp_options SET option_value = ‘‘ WHERE `wp_options`.`option_id` =1 AND `wp_options`.`blog_id` =0 AND CONVERT( `wp_options`.`option_name` USING utf8 ) = ’siteurl’ LIMIT 1 ;”;
$result = mysql_query($query);
$query = “UPDATE wp_options SET option_value = ‘’ WHERE `wp_options`.`option_id` =39 AND `wp_options`.`blog_id` =0 AND CONVERT( `wp_options`.`option_name` USING utf8 ) = ‘home’ LIMIT 1 ;”;
$result = mysql_query($query);

You can download the whole script here: reseturl.txt and modify the portion (underlined option above) that is applicable to your site. Rename the file to reseturl.php then upload it to your website. Execute it and that’s all it will reset the WordPress Address (URL) and Blog Address (URL) to appropriate URL.

I hope this script will solve your WordPress problem.


  1. ashley

    after searching the solution to my problem.. i just follow ur instruction and its works 100% for me..thank you very much..sori for bad english..Thanks and God bless.. you are the best..

  2. Again I screwed up, and again this helped! Thanks again

  3. Thanks for this.
    I was really fall in Big problem.
    You save me!
    Thanks A lot!

  4. shezoom

    I continue to receive errors…and have tried several variations on the reseturl.php including wonderful statements such as

    Parse error: syntax error, unexpected T_STRING in /home/content/m/b/s/mbsuccess777/html/blog/reseturl.php on line 5

    So then I took a look at the wp-config.php file…located the database name and info…and now get things like

    Error establishing a database connection

    Could I forward you both files … am so lost I’m feeling blonder each and every moment.

    1. You may send it to me shezoom and let me see if I can do anything about it.

  5. shezoom

    this sounds awesome! however how to you actually install it/run it? I made all of the recommended modifications in the script within notepad, saved it as a .php file, uploaded it to my site.

    Just don’t know where to go from here…

    1. Hi shezoom! it should be uploaded on your server where your WP was installed. Then change its attribute to executable (CHMOD 777) then run it via

      make sure you delete the file after you use it.

  6. It’s ok thanks. I went in to MySQL query browser and reset it there. Even though I couldn’t get the script working it does have the table name and ID number so I knew which values to change back.

    Many thanks

  7. Humm…

    I have copied the script you have above into a text editor and saved it as reseturl.php but unfortunately I get:

    PHP Parse error: parse error in \thisisnotmywebsiteurl\reseturl.php on line 5

    I then tried to download the script link you have reseturl.txt, but unfortunately I get a Error 404.

    Do you know what is happening??

    Many thanks

    1. thanks, the URL changed when I transfer this site to another hosting. I’ve just corrected it, thanks. You can download it right now.

  8. eamills

    Thanks so much for this! I’m a complete novice and I was able to get this work! Thanks again. This should be in the official WordPress documentation.

  9. Okay bleuken you are a life saver! After I reset all the data you mentioned above, the script worked like a charm. Thanks a million, the ite is back up and running……. 🙂

  10. Hi Look for this portion on your file wp-config.php

    define(‘DB_NAME’, ‘name-of-database‘); // The name of the database

    define(‘DB_USER’, ‘database-user‘); // Your MySQL username

    define(‘DB_PASSWORD’, ‘database-password‘); // …and password

    define(‘DB_HOST’, ‘localhost‘); // 99% chance you won’t need to change this value

    look for this values (on bold) and replace the value on the resetphp.url, if you want send me an email with the wp-config.php then I will send you the script.

  11. timewarpJFC

    bleuken sorry to be such a hassle I am not a database or web gurru and at a loss, and scard I have messed my whole site up. I

    I followed the instructions and I added the db username and db password as you mentioned above and copied them out of the wp-config file. Then I uploaded the renamed script of reseturl.php to the directory as you mentioned nothing happened. I tried typing the following in the browser and this came up.

    Warning: mysql_connect(): Can’t connect to local MySQL server through socket ‘/usr/local/mysql-5.0/data/mysql.sock’ (2) in /home/content/t/i/m/timewarpjfc/html/ovr25/reseturl.php on line 5
    Error connecting to mysql is the sub directory that my site is uploaded to.

    This all came from me accidentally typing in the url masking that I am using in the URL field in wordpress. I inserted and not the sub directory a I should have.

    any tips or guidance…

  12. @timewarpJFC, you should upload the script to your server after following the renaming instruction and replace user id and password with yours on the script which can be found from wp-config.php

  13. noob question here how do you execute the script?

  14. I cannot thank you enough for this script. It just saved my life! Well, maybe not my life, but over a month’s worth of work, that’s for sure.

    You rock!

  15. Oh man, you just saved my ass.. In an incredibly limited access environment where all I can do is edit files.. no ssh etc. Just pasted this into the top of index.php, ran it, then removed it.



  16. Yes that’s right. Delete the file after use, which i did after I’m done with it! Thanks Al! 😀

  17. …and make sure to delete the file from your server afterwards 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.