Changing default xampp htdocs location results in ‘Database Error’ (Mac OSX)

I’m trying to set up my Xampp htdocs location to a Google Drive folder so that I can work on my wordpress site from any location and also sharing it with my PC-laptop.

Following along some tips & tutorials (such as: how to change xampp htdocs directory in OSX?) I now can access my localhost. However, browsing to my wordpress site located in localhost/testsite/ results in:

Read More

‘Error establishing a database connection”

Any suggestions what can be wrong? Is it no possible to share htdocs-folder between PC & MAC?

my vhost.conf looks like (unchanged):

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/Applications/XAMPP/xamppfiles/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error_log"
    CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/Applications/XAMPP/xamppfiles/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "logs/dummy-host2.example.com-error_log"
    CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>

And the changes made to http.conf

DocumentRoot "/Users/username/Google Drive/htdocs"
<Directory "/Users/username/Google Drive/htdocs">

..

# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User username

UPDATE:

I’ve tried to make some changes to my wp-config.php file accordingly to some threads on this problem.

/** MySQL database username */
define('DB_USER', ''); 

/** MySQL hostname */
define('DB_HOST', '127.0.0.1'); 

Changes
– Removed root from DB_USER
– Tried changing DB_HOST to both Localhost (notice capital L) and 127.0.0.1. This makes the wp-config-file compatible with PC but just wanted to troubleshoot.

Localhost throws parse error and 127.0.0.1 results in “Error establishing a database connection”

Related posts

3 comments

  1. try accessing http://localhost/phpmyadmin and checking the credentials. Usually user is root and no password by default. Also, don’t forget to create a database for wordpress if you haven’t done so already. So your wp-config.php should contain something like this:

    define('DB_NAME', 'wordpress');
    define('DB_USER', 'root');
    define('DB_PASSWORD', '');
    define('DB_HOST', 'localhost');
    
  2. Architecturally, Google Drive was not designed for what you are trying to do. You may hack something together and get it working, but there are much better solutions.

    • VVV is a good solution for creating a local development server. It builds a box you control via the command line and can access through a browser anywhere on your LAN. You can a git based deployment strategy and have this box wherever you need it.
    • An even better solution is using Trellis, part of the Roots.io ecosystem. It uses Ansible to provision a ready-to-go vagrant instance and you can even deploy the entire server onto a bare-metal instance (like AWS or Digital Ocean). I have used this with great success, but you have to get more into the dev ops.
    • For cross-browser testing, I would recommend using browsersync as part of a gulp build process. You’d run gulp serve locally and, if you have browsersync as part of your build script, it will watch your codebase, automatically make updates for you in the browser and allow you to remotely access your local dev box for cross-browser testing.
  3. Alright, solution to this is far from revolutionary. Of course its not only the htdocs-folder that has to be synced between the PC and MAC but also the MySQL data folder.

    Exporting the database from phpmyadmin on the PC and importing it into my Xampp setup on Mac solve this problem with “Error establishing a database connection” message.

Comments are closed.