It reall depends on the hosting you use. I know alot use localhost for the database, but I am not sure how you would be able to do this unless you did it like this
I run a free webhost, and instead of localhost we use like..... sql4.exforce.info. So if they are running on the same site, all you have to do it set the database files the same. So you would edit the config.php file, and make sure that the password, username, database, host, and prefix are the same.
I would setup two databases, because its easier to edit the file after it exists. So you have them both set up. Then you need to choose which database you want to use. Then set in the config file to the database settings. Once you do that your login will the the same on both sites, and your posts will be synced together.