Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am working on a Wordpress site with another person. At the moment the Wordpress files are on a shared Dropbox folder, which allows both of us to see all the files we need to work on. However, Wordpress databases are not there, I've created them on my PC but the other person cannot see them.

Is there a standard, simple way to have Wordpress keep its database files in the same directory where all the other files are stored?

share|improve this question
3  
What database are you using for WordPress? Unless you use something like a SQLite database, you will not be able to sync it. MySQL will never sync. –  TFM Mar 16 '13 at 13:10
    
Are you talking about whole WordPress installation or backed up archived databases? I know that if you want others to collaborate, you would have to invite them by typing in their emails. This is done through Dropbox web interface. –  Boris_yo Mar 16 '13 at 13:21
    
@TFM MySQL, I would like to have my local databases on Dropbox together with all the other Wordpress files –  user1301428 Mar 16 '13 at 21:12
1  
Sorry, but this is not a good idea and is just not going to work the way you want it to. In particular, I'm afraid it's quite impossible with MySQL. You'd be better served setting up a server or a cheap shared web hosting account somewhere to host your site in development (or at least the MySQL server). –  tgies Mar 20 '13 at 7:46
1  
@user1301428 That's not the difficult part. The issue is that it's a Dropbox folder. Dropbox is going to go absolutely crazy and thrash around trying to keep the file in sync, and if you ever try to access the database at the same time as the other user, you're going to have concurrency issues. –  tgies Mar 20 '13 at 13:50

4 Answers 4

up vote 1 down vote accepted
+50

As I said in the comments, you really don't want to do this and I doubt it's going to work that well. You should really look into hosting an Internet-accessible MySQL server on a dedicated server/VPS, or on your or your collaborator's development machine. And if you do this, you need to be sure at the very least that only one of you has the database loaded at a time; I don't know how well Dropbox would handle syncing a bunch of concurrent updates to a database but my gut tells me it'd end in disaster.

That said, here is how you can tell MySQL to keep database files in an arbitrary directory, in this case your Dropbox shared directory.

You need to locate MySQL's configuration file. This is called my.cnf on most platforms, my.ini on Windows. To locate that file, see the answers here.

Having found the configuration file, open it and find a line starting with datadir. This is where your databases are now. Navigate to that directory and copy its contents to a new folder on your Dropbox. Now, change the datadir directive to refer to the path to your Dropbox, and restart MySQL.

share|improve this answer
    
Concurrency is not an issue, we would work on the database one at the time. What about setting up a local virtualized web server? –  user1301428 Mar 22 '13 at 11:09
    
Setting up a shared development web and MySQL server would be the way to go. –  tgies Mar 22 '13 at 13:57

You don't want to store the live database files in Wordpress, as recovering them will provide all sorts of grief and provide a false level of security. (For a number of reasons including that MySQL is not ACID compliant, the probable performance hit and because databases are not closed when making this backup, and recovery is harder even if you can get the data)

You would be better off - from a reliability, stability and recoverability point of view to back up the database using a cronjob to regularly do database dumps to your Dropbox folder. Thats what programs like MYSQLDUMP are there for (and they are part of the MySQL package - not an aftermarket add-on) You can schedule these dumps using CRONTAB.

For sharing access to the database, the correct behaviour is to set the database up on a port which can be connected too by both developers simultaneously. The whole point of databases is to abstract storage from code - so that multiple people can act on the data [more-or-less] simultaneously.

share|improve this answer
    
But if I set up the database on a port, the database itself must be on a web server to be always accessible I guess. So why shouldn't Dropbox be a good solution? –  user1301428 Mar 22 '13 at 11:07
1  
I guess you want to use a local mysql installation on both machines, using the mysql data from dropbox? On machine A something changes table X, and table Y depends on that table. This is not synced immediately, but takes some time. At the same time, machine B uses the same table. It changes something that is synced a little later, something that corrupts table Y on machine A. –  SPRBRN Mar 22 '13 at 15:48
1  
The database speaks a totally different language to a web server, and is an application with a defined set of interfaces designed to handle concurrent writes etc, not a simple file. Dropbox is not a solution because it does not run the application. The database does need to be always accessible, but does not need to be (and in large installations almost never is) on a web server. –  davidgo Mar 22 '13 at 19:03

I am not going to suggest you that its not good to treat databases like files when you need to work on it. Assuming, you know what you are doing, just locate datadir key ([mysqld] section) in my.cnf or my.ini (use mysqld --help --verbose to get location info) and change its value to Wordpress directory. Restart MySQL server. Done! You don't need to touch Wordpress configuration at all.

share|improve this answer
    
It's a development scenario! Who cares about what's safe? Worst possible outcome here is that the OP learns not to run several instances of mysqld on the same back-end files. –  Ярослав Рахматуллин Mar 23 '13 at 9:27

You might want to look at alternative solutions.

First, dropbox is a decent way to share files, but at best would be for one person sharing across multiple locations. I don't even know where to begin with the conflicts that you're going to run into trying to use dropbox as your source management system. Look into git or svn. svn is pretty user friendly with tortoise on windows, and there are places that offer free repos.

As for mysql, trust people here when they say you don't want to do this. You will trash your data, and quickly put it in an inoperable state. Since your using dropbox, reverting back to a operable state will be extremely difficult or impossible, depending on how well you did backups and timed them.

Your going to host the website somewhere, no? Don't they provide a mysql db for you to use? If so, you should check and see if you can expose ports for remote managing it, or just manage it through the hosts phpmySQL interface. Unless your making structure changes, you probably don't need to be in deep with the database anyways. You say that you have the DB on your machine but your friend can't access it, maybe you can open a port for him?

Finally, even if you did get the files to sync without trashing your data, he's still going to have to setup a MySQL instance on his side to do something with the datafiles. MySQL consists of two parts, the software and the data, you can't just dump the data into dropbox (or any sharing method) and have it be available to someone else who has access to the datafiles. If I'm mistaken and he does have mysql server configured, why can't he just install his own set of tables?

share|improve this answer
    
"why can't he just install his own set of tables?" He could, and he could import them every time there is an update I guess. I was just looking for a completely automatic solution. –  user1301428 Mar 23 '13 at 8:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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