How To Enable Remote Access To MySQL Server on Windows Server

It took me a bit to figure this out, which in reality is quite simple. These are the steps for a Windows Server to allow you to use programs such as Navicat or other fancy application based GUI to manage the MySQL database.

  1. Go to the Start Menu and select Run to open a Command Prompt
  2. Browse to the MySQL bin directory. I had to do
    C:>CD "Program FilesMySQLMySQL Server 4.1bin"

    Keep in mind that your directory structure might differ from mine depending on how you installed MySQL. Also you may have to do a few “Clear Directories” (i.e. “CD” or CD..) to get to the base of C:>.

  3. Type in:
    mysql -u root -p

    and enter in your root password when prompted.

  4. If you logged in successfully, you should see:
    mysql>

    and if not, then you will get something like:

    ERROR 1045 (28000): Access denied for user 'blah'@'localhost' (using password: YES)
  5. Enter in
    GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'IP' IDENTIFIED BY 'PASSWORD';

    What this will do is create a new user with ROOT privileges, so be very careful what account you are creating. If you are just using the root account, then replace USERNAME with root. And just so we are clear, USERNAME is the account you wish to create or use. IP is the physical IP address of the computer you wish to grant remote access to. If you enter ‘%’ instead of an IP number, that user will be able to remote access the MySQL server from any computer. PASSWORD is the password you wish to create if it’s a new user or the existing password of an existing account. And yes, you need to use the single quotation.

  6. And finally, you want to run this last command:
    mysql> FLUSH PRIVILEGES;
  7. To exit, just type:
    mysql> quit;

MAMP: Mac, Apache, MySQL, PHP

Introduction

Before my friend introduced me to MAMP (Mac + Apache + MySQL + PHP), I wasn’t really able to do much web producing commuting to work. I was limited to making site mockups using Adobe Photoshop CS2 and some basic coding, but I couldn’t actually make the pages until I had internet connection so I could upload my test site to the sandbox.

Then came along MAMP, an all-in-one application for Mac OS X that allows you to locally host a web server! This was fantastic because now I can develop, hard code, check changes, and make all the changes I want without having an internet connection. It also lets me test run PHP codes or scripts that may be unstable and vulnerable without risking the web server.

How To Install

Installing and configuring MAMP is very, very easy.

  1. Download the latest copy of MAMP from the MAMP website. After it is done downloading, double click the downloaded file to unzip the contents.
  2. Drag the MAMP folder into the Applications folder.
    MAMP Install 02
  3. Once MAMP has completed copying into the Applications folder, you can find the executable at Applications>MAMP>MAMP.
    MAMP Install 03
  4. When you start it up, you’ll notice two things will appear: (1) the MAMP admin panel and (2) http://localhost:8888/MAMP/?language=English loaded into your default web browser.
  5. From the admin panel you can stop and start the Apache and MySQL servers.
    MAMP Install 04
  6. Your default web url is http://localhost:8888/ and your public folder is located (by default) at Applications>MAMP>htdocs. So anything that is placed within the htdocs folder will appear at http://localhost:8888/. Please note that this web address is local only and others will not be able to see it or the contents even if your computer is connected to the internet. I’ve seen where some people have mistakingly thought that MAMP can be used as a live web server. No, this was only designed to allow people to work locally.
  7. To change the default location of what folder will be the web folder, in MAMP, go to the menu bar and select Preferences and then select the Apache tab. Enter or select a new location.
    MAMP Install 05

Mac OS X: Installing WordPress on Tiger

Please note that I did not write this. This is reprinted from MacZealots written by Matt Willmore. The only thing that has been changed is formatting, all else is exactly as the author written. This is here for my personal reference.

Of the many options out there, many people choose to run their own blogging software as opposed to a managed service like Blogger or TypePad. On the software side, there are many decent tools available, such as Six Apart’s Movable Type (we have a tutorial for installing MT as well). WordPress is another mature, capable and free blogging engine that is very popular with many bloggers (like its founding developer, Matt Mullenweg) and rapidly gaining in popularity across the Web. WordPress is an excellent choice for a personal or professional blog, and the price is right, too. This tutorial will show you how to install WordPress 1.5.1.3 on OS X 10.4 Tiger.

Note: The most recent version of WordPress is 1.5.1.3, which contains a security patch among other improvements. This tutorial is fully compatible with the most recent version of WordPress. Version 1.5.1.3 is recommended for all WordPress users (upgrade instructions).

If you have installed another blog engine such as WordPress or Movable Type already, you may already have MySQL and/or PHP configured. If this is the case, you can skip right down to step 4.

Before we get started, let’s summarize what we’ll be going over in the installation:

  1. Downloading and Installing WordPress 1.5.1.3
  2. Enabling Personal Web Sharing
  3. Downloading and Installing MySQL
  4. Configuring MySQL
  5. Enabling and Testing PHP
  6. Configuring WordPress
  7. ???
  8. Profit!

Downloading and Installing WordPress 1.5.1.3

If we’re going to blog our way to stardom, we’ll need some blogging software, right? The first step we’ll take will be to download the latest stable version of WordPress, version 1.5.1.3. The compressed file should be about 250KB, and OS X will decompress it for you.

Once it’s decompressed, we’ll move the wordpress directory to OS X’s Web hosting directory in /Library/WebServer/Documents. By default, all requests for the domain’s root directory (like http://maczealots.com/) will go to this directory. This can be changed in Apache’s httpd.conf file, which we’ll cover later. If you like, you can also change the name of the wordpress directory to something else, like blog. This way the URL of the blog would change to http://www.yoursite.com/blog/ Additionally, if you want the blog itself to be at the root directory, delete all the items from the /Library/WebServer/Documents directory and move the contents of the wordpress directory to the now-empty Documents folder.

Enabling Personal Web Sharing

‘Personal Web Sharing’ (PWS) is Apple’s marketing name for Apache, the industrial-strength, tried-and-true Web server du jour. When you enable PWS, OS X starts up Apache, registers the modules, opens ports, etc. Since we’ll be serving the blog, we’ll need to have Apache running.

To enable Personal Web Sharing, open the Sharing preference pane in System Preferences. Check the box labeled ‘Personal Web Sharing’, and that’s it. (You may have to authenticate as an administrator before it will let you enable anything.) Go ahead and close System Preferences; you’re ready to install MySQL now.

Note: We are working on a version of this tutorial that includes the ability to host the database with SQLite, which is prepackaged in OS X 10.4. However, support for SQLite in WordPress is still being fully developed, so for now MySQL is still the way to go. If you’d like to see such an article, let us know.

Downloading and Installing MySQL

MySQL is the database backend that WordPress (and other blogging packages like Movable Type) can use to store blog entries, users, comments, etc. MySQL is free for personal use. First, download MySQL (4.0.24 at the time of publication). It will come as disk image with two packages and a readme. We will be installing both packages. First, open the main MySQL installer. It will install all the necessary components to run MySQL onto your OS X volume. After that installer has completed, run the startup item installer, which will automatically start up MySQL after any computer restarts.

Note: One of the most common problems reported is that people install MySQL 4.1 instead of 4.0. I can understand the desire to be on the bleeding edge of software, but WordPress (and most other blog/CMS engines) use an older authentication scheme that is incompatible with MySQL 4.1 and greater. There are hacks and workarounds out there, but for the easiest installation, stick to MySQL 4.0.

Configuring MySQL

Now that you have installed MySQL, let’s configure it so WordPress can access it. Open a new terminal session (found in /Applications/Utilities/Terminal.app) and type the following commands to navigate, make some changes, and start the MySQL daemon:

cd /usr/local/mysql sudo chown -R mysql data/ sudo echo sudo ./bin/mysqld_safe &

Next, let’s launch MySQL and use the test database (called test, even) to make sure everything’s running correctly:

/usr/local/mysql/bin/mysql test

If everything’s running correctly, you should see output similar to this:

Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 1 to server version 4.0.24-standard Type 'help;' or 'h' for help.  Type 'c' to clear the buffer. mysql>

Once you’ve verified that MySQL is running correctly, use the command quit to return to the console prompt.

Now that MySQL is running, we’ll change the root password of MySQL so that WordPress (and you) can access it later. Use this command (where yourpasswordhere is replaced by your chosen password):

/usr/local/mysql/bin/mysqladmin -u root password yourpasswordhere

The last thing we’ll have to do in MySQL is to create a table for WordPress to store its data. We’ll call it wordpress to keep things simple. To accomplish this, we’ll enter MySQL, create the table, and allow WordPress to edit it.

/usr/local/mysql/bin/mysql -u root -p CREATE DATABASE wordpress; quit

Enabling and Testing PHP

Now that MySQL is ready to go, let’s fire up PHP. OS X ships with PHP installed, but not activated. Fortunately, this is really easy to do. The only file we’ll need to edit is httpd.conf, which Apache uses for its configuration.

Open the config file in your favorite editor (I’ll be using pico):

sudo pico /etc/httpd/httpd.conf

Mosey on down to the Dynamic Shared Object (DSO) Support section. It’s the one with all the LoadModule listings. The one for PHP 4 is towards the bottom of that list. Look for the line and uncomment it to activate it. You can uncomment a line by removing the pound symbol (“#”) from the beginning of the line. The new line should look as such:

LoadModule php4_module

We’ll also need to uncomment the PHP 4 entry in the AddModule listings, so that it looks as such:

AddModule mod_php4.c

Once those two lines are edited you can save the httpd.conf file and quit the editor. Since we’ve edited Apache’s load setup, we need to restart Apache so it will recognize the changes:

sudo apachectl graceful

With that out of the way, let’s make sure that PHP is indeed running. Create a new text file in your favorite editor (stay away from RTF-happy TextEdit, though – SubEthaEdit gets my vote) and fill it with the following text:

<?php phpinfo(); ?>

Save the file as test.php in the root directory (/Library/WebServer/Documents/) and load the address of the page (usually http://localhost/test.php) into a Web browser. If PHP was correctly enabled, the phpinfo(); command should output page after page about the PHP installation. If not, retrace your steps – it can be easy to make a mistake.

Configuring WordPress

Now for the last step: configuring WordPress. First, you’ll need to edit WordPress’ default configuration file wp-config-sample.php. You’ll find it in the root folder of the WordPress installation. This is where you’ll set up the database information. Edit the following settings:

define(‘DB_NAME’, ‘wordpress’); – Change ‘wordpress’ to the name of the database you created in MySQL (in the example we named it wordpress). define(‘DB_USER’, ‘username’); – change ‘username’ to root. define(‘DB_PASSWORD’, ‘password’); – change ‘password’ to the MySQL password you chose.

Once you’ve made the changes, save the file as wp-config.php in the same directory and delete wp-config-sample.php.

Now, open a Web browser window and start the WordPress installer, found at http://localhost/blog/wp-admin/install.php. (Remember that if you chose to install WordPress in a different directory, such as the root directory, the address will be different for you.) WordPress will take you through the install process and set up the database with all the tables it needs to run.

After it completes, it will give you the login (admin) and password to log in to WordPress. The password is randomly generated and not recoverable so please write it down!

After you log in, there are two things you need to immediately do. First, change your password to something you can remember. You can find it in the Users tab of WordPress’ controls. Also, to avoid posting entries as “Administrator”, you can either create another account with a posting name, or simply enter a nickname in the admin account. But whatever you do, change the password and remember it, once you lose it, your data is hard to get back.

Now comes the moment you’ve been waiting for. Click ‘View site in WordPress’ controls or open a Web browser and go to http://localhost/blog and watch your blog appear! Roll up your sleeves, perfect the CSS, and wax poetic, serving it to the free world without spending a dime on extra software. Happy blogging!

Mac OS X: Setting Up Apache, MySQL, PHP and Mod_Rewrite

Please note that I did not write this. This is reprinted from TextDrive written by SuperJared. The only thing that has been changed is formating, all else is exactly as the author written. This is here for my personal reference.

Step 1: Enable Apache.

Go to System Preferences > Sharing and enable Personal Web Sharing. Verify that Apache has started by opening a browser and pointing it to http://localhost/.

Step 2: Install MySQL.

This is almost as easy as enabling Apache since MySQL has excellent support for Mac OS X.

Go to http://dev.mysql.com/downloads/ and pick out the latest OS X flavored package. Make sure to get the right one for your architecture. Mount the dmg and you should see two installer packages: one for the MySQL database, and the other installs the MySQL startup item.

The easiest thing to do is just run the standard installer for the database. It should be called something like mysql-standard-VERSION-apple-ETC.pkg. After that is installed, install the file MySQL.prefPane by double-clicking it. This is a panel in the System Preferences that allows you to start, stop and configure the database for automatic start.

Your database is installed. Look into the MySQL documentation if you want to secure it, because right now, the user name is root and there is no password.

Step 3: Install PHP.

Go to http://www.php.net/downloads.php and download the latest source version. You’ll want to put this in your directory (that’s my preference, at least), so open up a terminal:

cd /usr/local/src/ sudo fetch http://path/to/the/latest/download/from/php.net/ sudo tar zxvf php-VERSION-ETC.tar.gz cd php-VERSION

At this point you’re in the PHP source directory. We’ll now configure our PHP. NOTE: This example has the bare minimum of options to get this all working properly. See the PHP documentation for more configure options.

sudo make sudo make install sudo cp php.ini-dist /usr/local/lib/php.ini

Make sure to edit to your desired settings. Now we need to edit httpd.conf:

sudo open -a TextEdit /etc/httpd/httpd.conf

And make sure these lines are in their proper locations:

LoadModule php5_module libexec/libphp5.so # Should have been added already AddModule mod_php5.c # Should have been added already AddType application/x-httpd-php .php

Now restart Apache:

sudo apachectl graceful

And verify that the install worked by creating a file called test.php under your Sites directory (/Users/myusername/Sites/) with the following text:

<?php phpinfo(); ?>

Go to http://localhost/~myusername/test.php to verify that it worked.

Step 4: Enable mod_rewrite. (Optional)

Enabling mod_rewrite requires additional modification of the httpd.conf (and related) files so we can use .htaccess files.

sudo open -a TextEdit /etc/httpd/httpd.conf

Under this line:

<Directory "/Library/WebServer/Documents">

You’ll see:

AllowOverride None

Change this to:

AllowOverride All

You’ll also want to modify your user’s configuration file:

sudo open -a TextEdit /etc/httpd/users/myusername.conf

The Options directive must include FollowSymLinks, and the AllowOverride should be AuthConfig All. Example:

<Directory "/Users/myusername/Sites/"> Options Indexes MultiViews FollowSymLinks AllowOverride AuthConfig All Order allow,deny Allow from all </Directory>

Restart Apache and you’ll be able to use .htaccess files.