1

Im trying to move my wordpress multisite to my host. I managed to copy all file, move the database to the host.

Also I edited databse settings on the wp-config file.

Did the same to the entries siteurl and home in wp_options table, and edited the wp_site table to hold the correct domain, did the same on the wp_blogs.

But it still shows that Error establishing connection to database message.. I tested a connection with mysqli_connect and its able to connect perfectly..

Im going crazy with this...

Have some of you struggled with this too?

PS: also tried to access backoffice and got this messages.

Could not find site optimystic.eu. Searched for table wp_blogs in database optimystic_db. Is that right?

What do I do now? Read the bug report page. Some of the guidelines there may help you figure out what went wrong. If you’re still stuck with this message, then check that your database contains the following tables:?

  • wp_users
  • wp_usermeta
  • wp_blogs
  • wp_signups
  • wp_site
  • wp_sitemeta
  • wp_registration_log
  • wp_blog_versions
  • You mentioned backoffice, can you explain what that is for those unfamiliar? – Tom J Nowell Oct 2 '18 at 12:17
  • Also, did the URL change? If so how did you change it? Did you do a search replace sql query? Or did you do things the correct way via a PHP command/script? – Tom J Nowell Oct 2 '18 at 12:20
  • @TomJNowell backoffice = /wp-admin = admin area of wordpress. I changed these values via MySQLWOrkbench manually in the database, wp-config .php was edited by hand in phpstorm – Miguel Pinto Oct 2 '18 at 12:28
  • 1
    Then that's your problem, you mangled serialised PHP values by changing the URL via an SQL statement rather than doing a proper search replace. That, or you manually changed a handful of options and the rest are unchanged – Tom J Nowell Oct 2 '18 at 12:40
  • 1
    If you're migrating to localhost though, do you really need to change the URL? E.g. with VVV you just use the same domain and it modifies the hosts file to point to your machine when it's running – Tom J Nowell Oct 2 '18 at 12:41
1

The problem is you ran an SQL query to change the site name. Doing this mangled and corrupted values that were serialised by PHP

Instead, use a Search replace script that will grab the values, deserialise, replace then re-serialise. WP CLI has such a command.

The reason for this is that the PHP serialised values contain the length of the URL, and by doing an SQL search replace, they are no longer valid. This breaks WordPress, leading to the problem you have. For this reason, an SQL query in an SQL client will never work.

Since you've already done this once on your database, you will need to undo the initial damage before you can run a search replace command via WP CLI

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.