[英]Migrate WordPress Multisite from localhost to public hosting (Error establishing a database connection
I'm a little desperate because I've been trying to find the problem I have for several days and there is no way.我有点绝望,因为这几天我一直在试图找到我遇到的问题,但没有办法。 I am new to WordPress but I have already developed several sites in PHP / Laravel.
我是 WordPress 的新手,但我已经在 PHP / Laravel 开发了几个站点。
But I have created a WordPress Multisite website in local and when I try to publish it to my IONOS hosting, after doing everything that needs to be done, I get the error "Error establishing a database connection", it does not say anything else.但是我在本地创建了一个 WordPress 多站点网站,当我尝试将其发布到我的 IONOS 主机时,在完成所有需要完成的事情后,我收到错误“建立数据库连接时出错”,它没有说任何其他内容。 In the browser console I see also a very generic error (Failed to load resource: the server responded with a status of 500 ())
在浏览器控制台中,我还看到一个非常普遍的错误(无法加载资源:服务器响应状态为 500 ())
The way to publish was as follows:发布方式如下:
Create site generated by the same hosting IONOS with all the Multisite configuration done automatically by this site, adding the lines indicated in wp-config.php:创建由同一托管 IONOS 生成的站点,所有多站点配置由该站点自动完成,添加 wp-config.php 中指示的行:
define( 'WP_ALLOW_MULTISITE', true );定义('WP_ALLOW_MULTISITE',真); define( 'MULTISITE', true );
定义(“多站点”,真); define( 'SUBDOMAIN_INSTALL', false );
定义('SUBDOMAIN_INSTALL',假); define( 'DOMAIN_CURRENT_SITE', 'xxxx' );
定义('DOMAIN_CURRENT_SITE','xxxx'); define( 'PATH_CURRENT_SITE', '/' );
定义('PATH_CURRENT_SITE','/'); define( 'SITE_ID_CURRENT_SITE', 1 );
定义('SITE_ID_CURRENT_SITE',1); define( 'BLOG_ID_CURRENT_SITE', 1 );
定义('BLOG_ID_CURRENT_SITE',1);
and in .htaccess:在 .htaccess 中:
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]
RewriteRule . index.php [L]
I have checked everything a thousand times and I do not understand what can be happening, the database access credentials in the wp-config are correct, in fact I did the test with a script checking the DB connection in case the DB host does not work but the connection was made correctly.我已经检查了所有内容一千次,但我不明白会发生什么,wp-config 中的数据库访问凭据是正确的,事实上,我用脚本进行了测试,检查数据库连接,以防数据库主机无法正常工作但连接正确。
Can someone give me a hand?有人可以帮我吗?
WP will not connect to database, until you change hosts to IONOS. WP 不会连接到数据库,直到您将主机更改为 IONOS。
wp_site
and wp_blogs
tables must be edited to connect.必须编辑
wp_site
和wp_blogs
表才能连接。
Use WP-CLI search-replace command.使用 WP-CLI搜索替换命令。
dry-run
shows preview without changing values. dry-run
显示预览而不更改值。
If local site is http
do this first:如果本地站点是
http
,请先执行此操作:
wp search-replace 'http://old.com' 'https://new.com' --all-tables --precise --dry-run
Then:然后:
wp search-replace 'old.com' 'new.com' --all-tables --precise --dry-run
Second command will change wp_site
table and some options.第二个命令将更改
wp_site
表和一些选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.