jonathanmoeller ([info]jonathanmoeller) wrote,
@ 2008-05-05 22:56:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
How To Install MySQL For Use With WordPress On Ubuntu 8.04
I seem to get a lot of web searches that are some combination of “WordPress”, “Ubuntu”, and “MySQL”. So I thought I'd write out a brief guide explaining how to install and create a MySQL database for use with WordPress on a local Ubuntu 8.04 installation. It is fairly simple to do, requiring only a few properly-typed Terminal commands, and can be done on either the Desktop or the Server editions of Ubuntu.

To begin, make your way to a Terminal window, and type the following command to download the MySQL server files and begin installation (always remember that commands are case-sensitive):

sudo apt-get install mysql-server-5.0

You'll need to enter your password. Follow the default prompts, and apt-get will download and begin installing MySQL. It's a big set of files, so the download might take a bit. Not far into the installation process, you'll be asked to provide a root password for MySQL. Just like the root user in Linux, the root user in MySQL has absolute control over all databases, tables, permissions, and users. For obvious security reasons, you'll want to create an extremely strong password (a mixture of uppercase, lowercase, numbers, and punctuation, the longer the better) for your MySQL root user.

Shortly thereafter, the installer will finish. You'll then need to activate MySQL with the following command:

sudo mysql_install_db

(Note: If you plan on using this installation in a production server, you'll probably want to run the mysql_secure_installation script.)

Once this command finishes, you'll need to log into the MySQL command-line client as the root user:

mysql -u root -p


Enter your MySQL root password. Once logged into the MySQL command line client, you will create a database for WordPress to use, a database user for WordPress, and grant all permissions on the database to the WordPress user.

First, create the database:

CREATE DATABASE wordpress;


(Note that all commands in MySQL must end with a semicolon to denote the end of the SQL statement.)

Create a user so that WordPress can access the database:

CREATE USER wordpressuser;


Next, set a password for the new user:

SET PASSWORD FOR wordpressuser = PASSWORD(“password”);

Just as with the root user, you'll want to choose a strong password. Note that your password will actually go within the quotation marks, and that the password is case-sensitive. For instance, if you were to choose 1234 as your password (an extraordinarily bad idea, incidentally), the command would look like this:

SET PASSWORD FOR wordpressuser = PASSWORD(“1234”);

The final step is to grant all privileges on your new database to the WordPress user by the following command. The password you just assigned the new user will go within the single-quote marks (and, yes, MySQL's internal syntax isn't always consistent):

GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser IDENTIFIED BY ‘password’;


Type exit to close the MySQL client.

You have just set up a MySQL database for use with WordPress. Of course, in order to run WordPress off Ubuntu, you'll also need the Apache web server, PHP, the PHP module for MySQL, and the WordPress software itself. To continue, you can see my guide to installing WordPress on Ubuntu 7.10 here, or you can view the official WordPress documentation here.

-JM


Create an Account
Forgot your login?
Login w/ OpenID
English • Español • Deutsch • Русский…