如何通过MySQL数据库修改WordPress网站的URL插图

WordPress uses the MySQL database to store all its data, including the site URL. Therefore, if you need to change the WordPress URL for some reason, it is necessary to adjust some data in the MySQL. Read on to learn how to do this.

1. 0 in MySQL database. Determine the name of the WordPress website MySQL database

if you have only one MySQL database, skip this section. However, if you have multiple databases and are not sure which database is connected to your WordPress, follow these steps.

WordPress stores the MySQL database name and its credentials in the wp-config.php file. You can find this file in the root file directory:

1. Access your pagoda panel and open the file menu.

2. Enter / www/wwwroot to select the corresponding domain name of the website and enter the WordPress installation directory.

如何通过MySQL数据库修改WordPress网站的URL插图1

3. Open wp-config.php and search for DB_NAME. The value of this parameter is your database name. For example, the name of our MySQL database is u923246418_gagap.

如何通过MySQL数据库修改WordPress网站的URL插图2

2. To change the WordPress URL

in the MySQL database to replace your current URL, perform the following steps:

1. Go to phpMyAdmin through the control panel of your website.

2. The left panel lists all your databases. Select the one that connects to your WordPress site, and then go to the SQL tab.

如何通过MySQL数据库修改WordPress网站的URL插图3

3. Enter the following SQL query:

UPDATE wp_options SET option_value = replace(option_value, 'oldurl.com', 'newurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';UPDATE wp_posts SET guid = replace(guid, 'oldurl.com','newurl.com');UPDATE wp_posts SET post_content = replace(post_content, 'oldurl.com', 'newurl.com'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'oldurl.com','newurl.com');

replacesoldurl.comwith your current WordPress address andnewurl.comwith your new WordPress address.

Note: your table prefix may not be wp_. View the correct table prefix on the left panel of phpMyAdmin and update the SQL query.

press start. You will see a success message and the number of rows changed. Note that the number of rows varies for each WordPress site.

如何通过MySQL数据库修改WordPress网站的URL插图4

the last thing we need to do is validate the changes. Open the wp_options table and check the option_value of siteurl and home. You should see the new URL.

如何通过MySQL数据库修改WordPress网站的URL插图5

if you receive an error message and the query is not executed, check your code for syntax errors and make sure you are using the correct table prefix. If the error persists with ​​, contact managed support for further assistance.

warm Tip: if you are changing the domain name of the whole site, you may also need to replace the old domain name old.domain.com with new.domain.com.

summary

through database search and replacement. We just learned how to use phpMyAdmin to change the WordPress URL in the MySQL database.

, as we have seen, all of the above steps are very simple. You just need to determine the correct database and enter some lines of code.

Disclaimer: All articles on this website, unless otherwise specified or marked, are original and published on this website. Any individual or organization is prohibited from copying, stealing, collecting, or publishing the content of this site to any website, book, or other media platform without the consent of this site. If the content on this website infringes on the legitimate rights and interests of the original author, you can contact us for assistance.