How to set up and edit the MySQL database


Setting up the MySQL Database

It's almost time to install WordPress, but first, you need to create a MySQL database for WordPress to store all your content and user accounts. The installation will fail if you don't set this database up beforehand. Delving into the ins and outs of setting up a MySQL database is beyond the scope of this book, but here are some pointers:

The database user who installs WordPress needs to have full rights over the WordPress database, meaning that the user can create- and delete-all manner of things. A good password is your best defense against malicious tomfoolery.

Editing the wp-config File

This article assumes that you're using WordPress 2.6. Most of the information will be valid for older versions, but you may notice some differences if you aren't using WordPress 2.6.

Now that all the prep work is done, you're ready to get your hands messy with a little WordPress code. If you're code squeamish, worry not! The file you're about to look at is honest-to-goodness PHP code, but I'm here to help you. Look inside the wordpress folder on your computer, and open the file called wp-config-sample.php. You should see a bunch of code, along with some very helpful comments about what you should, and shouldn't, touch in this file. The wp-config file has four parts, which I'll call MySQL database Settings, KEY, Languages, and "not for editing."

MySQL database Settings

The MySQL database Settings part is how WordPress knows where to look for the MySQL database you set up earlier. All you need to do is enter some information in this file. Remember to enter all your values between quotation marks; otherwise, your install will fail. Here's the text of this part:

// ** MySQL settings ** //
   define(‘DB_NAME', ‘putyourdbnamehere');
   // The name of the database
   define(‘DB_USER', ‘usernamehere');
   // Your MySQL username
   define(‘DB_PASSWORD', ‘yourpasswordhere');
   // ...and password
   define(‘DB_HOST', ‘localhost');
   // 99% chance you won't need to change this value
   define(‘DB_CHARSET', ‘utf8');
   define(‘DB_COLLATE', ‘');

And here's what you need to fill in:

One database setting in the default wp-config file isn't grouped with the others, but it's very important if you plan to point multiple WordPress installs to one MySQL database. $table_prefix allows you to set a custom table prefix for each WordPress install. The default prefix is wp_, which means that every table created by the install will have wp_ as its first three characters. This arrangement is fine if you plan to have only one WordPress install per MySQL database, but if you want to use one database for more than one WordPress Blog, you need to set a custom prefix for each blog.

KEY

Here's the text of the KEY part:

 define(‘AUTH_KEY', ‘put your unique phrase here');
   // Change this to a unique phrase.
   define(‘SECURE_AUTH_KEY', ‘put your unique phrase here');
   // Change this to a unique phrase.
   define(‘LOGGED_IN_KEY', ‘put your unique phrase here');
   // Change this to a unique phrase.

The KEY part is all about making your installation of WordPress more secure. You may be tempted to skip this part because it's optional, but it's such a great way to secure your WordPress Blog that it's well worth a few seconds of your time. What do these keys do? WordPress uses cookies-little files that are stored in your Web browser to remember who you are and what your login information is. A hacker could grab one of your cookies and log into your blog posing as you. Setting these keys lets WordPress hash those values to make it much harder for someone to get any information from the cookies. These keys are also used in your MySQL database to make the passwords stored there harder to decipher. The keys work best when they're completely random and more than 60 characters long. I have two pieces of good news that will make using these keys seem much more attractive:

1. You never have to remember the values of these keys. You set them once in your wp-config file and then forget about them (though they'll be stored in the file itself, should you feel nostalgic for them).

2. The smart folks behind WordPress set up a service that generates three very strong, and very random, keys for you. All you have to do is visit http://api.wordpress.org/secret-key/1.1/, which generates the code for you; just copy and paste that code into your wp-config file. Nothing could be easier.

Languages

The default WordPress language is English, which is great for us Englishspeaking bloggers. But what if you want to blog in another language? That's where define comes in. Localizing WordPress to another language requires a few steps:

1. Define WPLANG to the language code you want.

2. Create a folder called languages inside the wp-content folder of your WordPress installation folder.

3. Obtain the proper MO file for the desired language, and put it in your new language folder.

The MO file contains all the information that WordPress needs to be displayed in anything from Italian to Portuguese. Volunteers create these files, some of which are available here: http://codex.wordpress. org/WordPress_in_Your_Language. You can also find a full list of the codes needed to define the WPLANG variable to your language of choice.

"Not for editing"

Astute readers will note that I didn't mention the final part of the wp-config file:

if ( !defined(‘ABSPATH') )
   define(‘ABSPATH', dirname(__FILE__) . ‘/');
   require_once(ABSPATH . ‘wp-settings.php');

I have a very good explanation for this omission: You shouldn't edit that part of the file. The wp-config file acts as a repository for settings that another file-wp-settings.php-uses to do all the heavy lifting of the WordPress installation. Fiddling with this part of the file will result in installation errors, so don't touch it!

Legal Disclaimer

Our website is not responsible for the information contained by this article. Webworldarticles.com is a free articles resource thus practically any visitor can submit an article. However if you notice any copyrighted material, please contact us and we will remove the article(s) in discussion right away.


This article was sent to us by: Herald D. Baker at 01262010

Related Articles

1. What pages and advertising should my website have
Content Best Practices The subject of your content is really up to you, but there are some best practices for any content. Content should be personal - ...

2. How to create a MySpace profile to build your Social networking experience
One of the benefits of these websites is that they allow you to promote your website to other people. I am a member of all of these websites, and when I publish a new b...

3. How to efficiently manage user accounts and profiles in WordPress Blogs
How to manage user accounts in your WordPress Blog The software is installed and running, and you've logged in to WordPress as an administrator. I bet that yo...

4. Tips for future proofing your WordPress Blog
How to future proof your WordPress Blog There's one last bit of business to take care of before I delve into populating your WordPress Blog with some awesome ...

5. Reading is another aspect of blogging
Reading Settings The other side of the blogging coin is reading. Your WordPress Blog won't be much fun if no one reads it, though don't be fooled into thinking ...

6. Settings to help you reduce comment spam
Discussion Settings I've covered settings that govern how you post to your WordPress Blog and how people read your blog, so what's left? Commenting, of course. ...

7. Shop drawing liability: Review process and 3D structural modeling
Over the last two decades, many advancements have occurred in the production of shop drawings due to advancements in computer technology. The developments in computer-aided...

8. Introduction to Web Accessibility
Interaction refers to anything that requires some action from the visitor, such as clicking on a link or fi lling out a form, as a way to, or the next step toward, reachi...

9. Design a website following some easy steps
Design an effective website Creating a very effective online presence is what you have to do, if you want to effectively promote your company online. Including ju...