Accessibility

Dreamweaver Article

 

Setting up a PHP development environment for Dreamweaver


Table of Contents

Install MySQL on your computer

You can use a MySQL database server running on your computer to develop PHP applications in Dreamweaver. This section describes how to install the MySQL Community Server 5.0 on your Windows or Macintosh computer. MySQL is open source software that you can use for developing and testing web applications. For more information, see the MySQL documentation at http://dev.mysql.com/doc/refman/5.0/en/index.html.

Topics covered in this section:

Install MySQL in Windows

This section describes how to download and install the MySQL 5.0 Community Edition database server on your Windows XP computer.

Note: The instructions in this section apply to the "Windows Essentials" installer for MySQL 5.0 in Windows XP. For other versions, please see the MySQL documentation for possible differences in the installation procedure.

  1. Download the "Windows Essentials (x86)" installer from the Windows Downloads category on the MySQL download page:

    http://dev.mysql.com/downloads/mysql/5.0.html#win32

  2. Double-click the MSI file you downloaded and follow the onscreen instructions.

    Note: Select Typical Install when prompted.

  3. When the setup wizard is done, run the configuration wizard by making sure the Configure the MySQL Server Now option is selected on the setup wizard's last page and clicking Finish.

    Note: If you missed the option in the setup wizard, you can open the configuration wizard by selecting Start > All Programs > MySQL > MySQL Server 5.x > MySQL Server Instance Config Wizard.

  4. In the MySQL Server Instance Configuration Wizard, make the following choices:
    • For configuration type, select Detailed Configuration.
    • For server type, select Developer Machine
    • For database usage, select Non-Transactional Database Only.
    • For the number of concurrent connections, select Decision Support(DSS)/OLAP.
    • For networking options, accept the default settings.
    • For the default character set, accept the default setting.
    • For the Windows options, select both options – Install As Windows Service, and Include Bin Directory in Windows Path.
    • For security options, enter a root password and confirm it.
  5. Click Execute to configure your database server.

    Now you can verify that the server is working correctly.

  6. Start the MySQL Command Line Client by selecting Start > All Programs > MySQL > MySQL Server 5.x > MySQL Command Line Client.
  7. Enter your password (if any) at the command line, and then press Enter.

    The MySQL client's command prompt appears, as follows:

    mysql> 
  8. To verify that MySQL is running, enter the following line at the MySQL command prompt:

     SHOW DATABASES; 

Note: Make sure to include the semi-colon and then press Enter.

If MySQL is working correctly, it should list three databases: information_schema, mysql, and test.

The next step is to create a fourth database in MySQL called CafeTownsend and populate it with sample data.

Create the sample database in Windows

  1. Locate the the SQL script file, tutorial.sql, in the sample files included with this tutorial and copy it in the bin folder in your MySQL installation folder.

    For a normal installation, the bin folder is located at the following path:

    C:\Program Files\MySQL\MySQL Server 5.x\bin\
  2. If not already done, start the MySQL database server.

    To check to see if it's started, select Start > Control Panel > Administrative Tools, then double-click the Services shortcut. In the Services dialog box, make sure the status of the MySQL item is listed as "Started". If not, select the item, right-click, and select Start.

  3. Start the MySQL Command Line Client by selecting Start > All Programs > MySQL > MySQL Server 5.x > MySQL Command Line Client.
  4. Enter your password (if any), and then press Enter.

    The MySQL client's command prompt appears, as follows:

    mysql> 
  5. Create a new database by entering the following command at the MySQL prompt:

    CREATE DATABASE CafeTownsend; 

    Note: Make sure to end the line with a semi-colon and then press Enter.

    MySQL creates a new database, but it doesn't contain any tables or records yet.

  6. Log out of the MySQL client by entering quit; (with semi-colon) and pressing Enter.
  7. Open the Windows command prompt by selecting Start > Run, and typing cmd in the Run dialog box.
  8. At the system command prompt, populate the new CafeTownsend database by entering or pasting the following commands, pressing Enter at the end of each line:

    cd \
    cd Program Files\MySQL\MySQL Server 5.0\bin
    mysql -uroot -pPassword CafeTownsend < tutorial.sql

    If you specified a username during the MySQL setup, replace root with your username. For example, if your username is devdude, then enter -udevdude. If you didn't specify a username at setup, you must still enter -uroot.

    Make sure you replace Password with your MySQL password. For example, if your password is Te22y01, then enter -pTe22y01. If you didn't specify a password, omit the -pPassword item completely.

    This command uses the tutorial.sql file to insert tables and records to the CafeTownsend database.

  9. To verify that the CafeTownsend database was populated, start the MySQL Command Line Client again (see step 3) and then enter the following command at the MySQL prompt:

    SHOW TABLES IN CAFETOWNSEND;

    MySQL should list the comments, locations, and region tables as follows:

    MySQL showing the comments, locations and region tables

    Figure 1. MySQL showing the comments, locations and region tables

    After creating the sample database in MySQL, connect to it in Dreamweaver as described in Connect to the database.

Install MySQL on a Macintosh

This section describes how to download and install the MySQL 5.0 Community Edition database server on your Macintosh.

Note: The instructions in this section apply to the package format (DMG) installer of MySQL 5.0 for the Macintosh. For other versions, please see the readme file that comes with the installer for possible differences in the installation procedure.

  1. Download an installer package from the "Mac OS X (package format) downloads" category on the MySQL download page:

    http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg

    If your Mac has an Intel processor, select the "Mac OS X 10.4 (x86)" package. Otherwise, select the "Mac OS X 10.4 (PowerPC, 32-bit)" package.

    Double-click the DMG file you downloaded (example, mysql-5.0.41-osx10.4-i686.dmg).

    Your computer mounts the disk image and displays the contents, which include the installer file (example, mysql-5.0.41-osx10.4-i686.pkg).

  2. Double-click the installer file (PKG) and follow the onscreen instructions.

    If you have an Intel Mac, you may see the following error message in the destination disk selection dialog box: "You cannot install this software on this disk. (null)." If this error occurs, click the Go Back button once to return to the previous screen, and then click Continue to advance to the dialog box again. You should now be able to choose the destination disk.

  3. After the installation of the database server is complete, install a button to start and stop the database server by double-clicking the MySQL.prefPane file in the installation disk image, and then following the onscreen instructions.

    This small installer places a stop and start button in your system preferences to control the server. The button can be accessed through a new MySQL button under the Other category in the Preferences dialog box.

  4. On the Macintosh, open Terminal (in Applications > Utilities) and enter the following instructions at the command line:

     cd /usr/local/mysql
    sudo ./bin/mysqld_safe
  5. Enter your Macintosh password, if necessary, and press Return.
  6. Press Control-Z, then at the command line enter bg and press Return.
  7. End the session by pressing Control-D, or enter exit.
  8. Start the database server by selecting Apple > System Preferences, then clicking the MySQL button under the Other category of preferences. In the dialog box that appears, click the Start MySQL Server button.

    Note: To stop the server, click the button again. If you want the database server to start automatically every time you start your Mac, select the Automatically Start option in the dialog box.

  9. Start a new Terminal session and enter or paste the following instruction at the command prompt: /usr/local/mysql/bin/mysql -uroot

    The MySQL command prompt appears:

    mysql >
  10. To verify that MySQL is running, enter the following line at the MySQL command prompt:

    SHOW DATABASES; 

    Note: Make sure to include the semi-colon and then press Return.

    MySQL should list the following databases:

    MySQL listing the databases

    Figure 2. MySQL listing the databases

The next step is to create a fourth database in MySQL called CafeTownsend and populate it with sample data.

Create the sample database on a Macintosh

  1. Locate the the SQL script file, tutorial.sql, in the sample files included with this tutorial and copy it into the Documents folder in your home folder.
  2. If not already done, start the MySQL database server by selecting Apple > System Preferences, then clicking the MySQL button under the Other category of preferences. In the dialog box that appears, click the Start MySQL Server button.
  3. Start a new Terminal session and enter or paste the following instruction at the command prompt:

    /usr/local/mysql/bin/mysql -uroot

    The MySQL client's command prompt appears, as follows:

    mysql> 
  4. Create a new database by entering the following instruction at the MySQL prompt:

    CREATE DATABASE CafeTownsend; 

    MySQL creates a new database, but it doesn't contain any tables or records yet.

  5. Log out of the MySQL client by entering quit; (with semi-colon) and pressing Return.
  6. At the system command prompt, populate the new CafeTownsend database by entering or pasting the following command:

    /usr/local/mysql/bin/mysql -uroot CafeTownsend < ~/Documents/tutorial.sql 

    This command uses the tutorial.sql file to insert tables and records to the CafeTownsend database.

  7. To verify that the CafeTownsend database was populated, return to the MySQL command line (see step 3) and then enter the following command at the MySQL prompt:

    SHOW TABLES IN CAFETOWNSEND;

    MySQL should list the comments, locations, and region tables as follows:

    MySQL showing the comments, locations, and region tables

    Figure 3. MySQL showing the comments, locations, and region tables

After creating the sample database in MySQL, connect to it in Dreamweaver as described next.