Local Community

Database location working as expected?

Issue Summary

I regularly work on two different computers and have been trying to rely on LocalWP to work on sites on both computers. I thought this would be possible because, as indicated in threads like this (Location of database files and software), it’s my understanding that LocalWP is supposed to save out the database to [site directory]/app/sql/local.sql, and when the site is launched, it uses that sql file to rebuild the database.

However, in my exprience, that’s not what happens at all. The SQL database is kept in the user Library, and while it might save a copy of the database to the sql file, it doesn’t load it from that file when it’s relaunched.

As a result, if I work on a site on one computer, shut down the site, then move to another computer, while the site files might be correct, the database will be whatever it was when I last worked on the site on that computer.

Troubleshooting Questions

What is this expected behavior for LocalWP?

Should the site files be completely independent of the computer it’s being worked on, or should it be defaulting to the existing database files save in the local user directory?

Replication

Set up a site on one computer on an external drive.
Move that drive to another computer, archive and import the existing directory on a second comptuer.
Make a database change (alter page content).
Move the drive back to the first computer, the page content will not have the database change.

System Details

  • Which version of Local is being used? 6.6.0

  • What Operating System (OS) and OS version is being used? MacOS Ventura (13.0.1)

I was hoping for some sort of feedback on this?

Currently, after starting the site on a different computer, I’m running the SQL file found in /app/sql/ to re-import the database and get it up to date.

This part is correct:

I thought this would be possible because, as indicated in threads like this (Location of database files and software ), it’s my understanding that LocalWP is supposed to save out the database to [site directory]/app/sql/local.sql

but as far I know, this part is not:

and when the site is launched, it uses that sql file to rebuild the database.

The database is dumped out to the local.sql file on shutdown (primarily for backup purposes, I suspect), but isn’t re-imported to the database on starting a site. In most cases, there isn’t a need to re-import it, as they should already contain the exact same database structure and data.

When you move the drive from one machine to another, it sounds like you’re moving the site files, but not the database files. The database files (not the local.sql dump file) are stored separately from the site files. Per the image linked in the thread you referred to (Image 2022-10-05 at 3.20.18 PM), you’ll see that on MacOS it’s within a site-specific folder under the /Users/[user]/Library/Application Support/Local/run/[site-folder]/mysql/data directory. I don’t know if moving those database files between machines will cause issues.

But, as you mentioned, you can always manually import the local.sql file to the database on each machine after starting the site in Local.

I know there have been threads in the past that discussed trying to work on the same site across multiple machines. I don’t know if any of them have had any real success, but perhaps there are relevant suggestions in those that might help you.

1 Like

Thank you for the clarification! I get that it’s a niche case, as most people are probably working on a site from a single computer. It would be nice if there was a ‘force import’ option that could be turned on.