Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress Local WordPress Development Local WordPress Development Migrating WordPress from Local to Live Server

Leslie Askew
Leslie Askew
443 Points

Error establishing a database connection

Hi,

I've configured wp-config.php to the text below and am getting the Error establishing a database connection when I try to browse the remote host.

I would be very grateful if you could let me know what I'm doing wrong?

Many thanks

Leslie

<?php /**

  • The base configuration for WordPress *
  • The wp-config.php creation script uses this file during the
  • installation. You don't have to use the web site, you can
  • copy this file to "wp-config.php" and fill in the values. *
  • This file contains the following configurations: *
  • * MySQL settings
  • * Secret keys
  • * Database table prefix
  • * ABSPATH *
  • @link https://codex.wordpress.org/Editing_wp-config.php *
  • @package WordPress */

// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', ‘c3321877_localwp’);

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

/** MySQL database password */ define('DB_PASSWORD', 'frogleg5');

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

/** Database Charset to use in creating database tables. */ define('DB_CHARSET', 'utf8mb4');

/** The Database Collate type. Don't change this if in doubt. */ define('DB_COLLATE', '');

define(‘WP_HOME’, ‘c3321877.myzen.co.uk’); define(‘WP_SITEURL’, ‘c3321877.myzen.co.uk’);

/**#@+

  • Authentication Unique Keys and Salts. *
  • Change these to different unique phrases!
  • You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
  • You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again. *
  • @since 2.6.0 / define('AUTH_KEY', '!|{Np&<y$TO(6@hA<OaFRL^:ROQS0;@x@Uv-<:I 7Dun54q3S_a?BzyX?~W0DMo'); define('SECURE_AUTH_KEY', ' XE831,]vDiOkdAA[=)+$ U#fJ$UvlFR;0UVvsxO+Y!DV:%kk^<%Yz:FM$7Fo_'); define('LOGGED_IN_KEY', 'ryQWV8JSwGb%j1v+}beY.oi1d>S&oUTyRnz(p-OH%[.36-bjQ$h@Uz,2lJWgnk'); define('NONCE_KEY', 'TeB3A0I,v8(YGqj?Ad=<+2AnHK@P;<IC~[Pn`T65:fM>6<o%=ICBU%;*A1XEPag{'); define('AUTH_SALT', 'FzITJWm#.viD>L7Anl:>)4>)@SMO:_ubDu5:V?DkfC!S9kHOj~y-<@#K%t=>1Us'); define('SECURE_AUTH_SALT', '4}<4Z+[Rv|ptbgvU4crKSwql_0]v*sL*G~(0-RI{d +]pa/v0KKhk Ek[Yp>CRL'); define('LOGGED_IN_SALT', 'c3sTe]oCS6oh(6}dgwU/$*ryuPhGbd?DZ%4nDS!H=a/*M;{P{a}gH&y.MPkxq:s'); define('NONCE_SALT', '-u:A=@XLnpDWtU~ ]jlN-vzJ0b~0{8;TFJcmbDe+e8Iqf=13(_BKvx-GyI@2_Pd');

/*#@-/

/**

  • WordPress Database Table prefix. *
  • You can have multiple installations in one database if you give each
  • a unique prefix. Only numbers, letters, and underscores please! */ $table_prefix = 'wptest_';

/**

  • For developers: WordPress debugging mode. *
  • Change this to true to enable the display of notices during development.
  • It is strongly recommended that plugin and theme developers use WP_DEBUG
  • in their development environments. *
  • For information on other constants that can be used for debugging,
  • visit the Codex. *
  • @link https://codex.wordpress.org/Debugging_in_WordPress */ define('WP_DEBUG', false);

/* That's all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */ if ( !defined('ABSPATH') ) define('ABSPATH', dirname(FILE) . '/');

/** Sets up WordPress vars and included files. */ require_once(ABSPATH . 'wp-settings.php');

2 Answers

Kevin Korte
Kevin Korte
28,149 Points

Usually this happens when you're database name, username, or password are wrong. Check those against what's set up on the server.

Leslie Askew
Leslie Askew
443 Points

Thanks, Kevin.

Turns out I had a problem with my single quote. The wp-config.php wants a kind of straight up and down one of these:

'

and mine ends up curly. Is there a known Mac keyboard issue with making the correct keystroke for quotes in php?

Many thanks