Setup MySQL for local Wordpress development - martindubenet/Wordpress GitHub Wiki
[ Home ][ Plugins ][ Functions ][ MySQL setup ]
Create your local database
| Mac MAMP | Mac MAMP PRO | Windows WAMP | |
|---|---|---|---|
| default port | :8888 |
demo:8889 |
:3308 |
| phpmyadmin | http://localhost:8888/phpmyadmin/ | http://demo/phpmyadmin/ | http://localhost:3308/phpmyadmin/ |
MySQL Workbench
A youtube tutorial on « How to install Workbench version 8.0.22 on macOS M1 ».
- https://www.mysql.com/products/workbench/
- How to Setup MySQL Workbench Database for WordPress on Windows Server
phpMyAdmin
- Create a new database. (Note: by default Wordpress is requirering that your database name starts with
wp_as a prefix) - Once created you will be automatically redirect to « Structure » tab but you have nothing to fill there.
- Click on « Priviledges » from navigation tab.
- Click on the « Create a new user » link available down in the page.
- Fill in a
User name(alphanumeric characters only), - Enter a simple
PasswordandRe-typeit a second time, - Global privileges
✅ Check all - Click the « Go » button in the bottom right corner of the page.
- Fill in a
Fill in your database infos
- Before launching it, copy/paste
/wp-config-sample.phpfrom the root directery of Wordpress. - Rename that copied file to
/wp-config.php. - Open
/wp-config.phpto edit the following MySQL settings:
Since WAMPserver now install MariaDB by default, if you use the traditional MySQL database set-up, you need to add the Port defined for MySQL value that is defined on the
localhostpage. So far mine is3308but that can change.
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );
/** MySQL database username */
define( 'DB_USER', 'root' );
/** MySQL database password */
define( 'DB_PASSWORD', 'root' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' ); // default
define( 'DB_HOST', 'localhost:8889' ); // MAMP (macOS)
define( 'DB_HOST', 'localhost:3308' ); // WAMP (Windows)
Advance options for your « wp-config.php »
Set URL of the site landing page
Force the bloginfo( 'url' ) value that defines the home_url() function. PHP over-rules de database value without erasing it from mySql and maximise performance in the meantime. Now it is safer and faster to use <?php echo esc_url( home_url( '/' ) ); ?> in your theme header & footer templates.
define( 'WP_HOME', 'https://example.com' );
Set the path to the solution
https://wordpress.org/support/article/giving-wordpress-its-own-directory/
Force bloginfo( 'wpurl' ) value that defines the site_url() function. This allows you to move the solution within a sub-directory making the root of your site more zen.
define( 'WP_SITEURL', 'https://example.com/wordpress' );
If you get in trouble after follow these instructions to fix the issue using your theme's
function.phpfile that you'll access via FTP.
Desable auto-updates
This is useful for professional developpers that prefers stability over « freedom to bug-and-break » that come free updates on old projects.
define( 'WP_AUTO_UPDATE_CORE', false );
Limit the amount of revisions
This helps keeping the database from inflating by flushing older backups that in real life are not used often.
define( 'WP_POST_REVISIONS', 4 );
Launch Worspress for the first time
http://localhost/example.com/wp-admin/install.php- The
install.phpwill ask to choose the default language for the admin view. - Fillin the basic informations for your Wordpress site:
Site Title,Use name,Password,Your Emailand, if your are developping a new site live on a server, make sure to check the optionSearch Engine Visibility ✅so the<meta name="robots">content value will display noindex,nofollow until you uncheck it from the Dashboard. - Click Install Wordpress and you're done!