PHP and MySQL in Dreamweaver MX
by Allan Kent

This tutorial will walk you through the following:

  •  Installing MySQL
  •  Set up of phpMyAdmin
  •  Creating your database
  •  Connecting to database
  • Introduction

    MySQL is an extremely popular Open Source database management system that is licensed under the Gnu General Public License.  It is available for almost all of the popular OS platforms and most Internet Service Providers will have MySQL installed and available for you to use as part of your hosting contract.  For those of you who are writing applications that will violate the GPL. MySQL also offers a commercial license, which is very reasonably priced.  We're not going to get into the details of what does and does not constitute a violation of the license - the MySQL web site has the full details (http://www.mysql.com/products/licensing.html) and examples of what you can and can't do with it.  What we will be doing in this article and the next is getting an overview of how you can get going with PHP and MySQL in Dreamweaver MX.  This article will concentrate on getting it all up and running.

    Getting and setting up MySQL

    The first thing that you will need to do is get and install MySQL.  We're going to assume that you've managed to get PHP installed and configured for your web server, be it IIS, Apache or  any of the many others. 

    As we said earlier, MySQL is Open Source, so if you are that way inclined, you can grab the MySQL source code and compile it yourself.  For those of you who just want to get it up and running with minimal fuss, the MySQL web site provides binary installation versions of MySQL for you to download and install. 

    MySQL is currently available as two different versions. Version 3.23 has been tested extensively in production environments and is the version you should use if you intend to deploy your application in a production environment. 
    Version 4.0 is currently in gamma - it's beyond the beta stage, and has been used for over 2 months without any serious bugs.  You should choose this version if you are doing new development.  I use version 4.0 for all of my internal development and testing and it has been perfectly stable.  The additional features in version 4 include speed enhancements, a new storage engine that supports transactions and low-level locking, and several other enhancements.  At the time of writing Version 4.1 was announced as available, but there are currently no binary versions - source code only.

    When you come to download MySQL you will notice that you can choose between Standard and Max.  The Max version includes features that have not been thoroughly tested as well as debug information and should be used only if you wish to make use of these features.  Since we won't be using any of the additional features introduced by version 4.0, you can download and install whichever version you prefer - http://www.mysql.com/downloads/index.html

    Most hosting companies will already have MySQL set up for you, so we'll look at setting up MySQL for developing on your local machine.  The Windows installation comes in the form of a Windows setup program - simply unzip the archive and run the SETUP.EXE file and install MySQL to its default location of C:\mysql.

    To start MySQL, open a Command Prompt and change to the C:\mysql\bin folder.  Type the command

    C:\mysql\bin>mysqld --console

    This should display the message mysqld: ready for connections.  You can now either leave this window minimized, and move onto setting up phpMyAdmin, or if you are running Windows NT, 200 or XP, install MySQL as a service.  To do this stop the current console version of MySQL in the Command Prompt by typing Ctrl-C.  When you are back at the prompt, type

    mysqld --install

    MySQL will now appear in your Services control panel and you can start and stop it from there.

    Allan Kent

    Allan KentAllan comes from Cape Town, South Africa. He has been implicated in writing for several WROX, glasshaus, Wiley and Apress publications, generally in the 'cool stuff that PHP can do' sections.

    You can catch up with him at his website http://www.mediafrenzy.co.za.

    See All Postings From Allan Kent >>

    Place your comment about PHP and MySQL in Dreamweaver MX




    You must me logged in to write a comment
    Comments
    first timer
    December 20, 2008 by g e

    I really just started into mysql. I avoided it up until this point, but I had issues with a forum. I get it now!! Very powerful. Another simply type tutorial is here: <a href="http://www.siteground.com/tutorials/cpanel/mysql.htm">Mysql Tutorial</a>

    Setting up in windows
    July 15, 2008 by Howard Walker Walker

    I do not know where this information comes from, but as a windows user it seems to be totally out of date. Perhaps it is due for an update?

    Mysql is not accessible as described, the default location is in Program files\MySQL Server 5.0\ and access to it is from the start button. Attempting to access it from the command prompt gives an error message.

    Copying the files into a directory like C:\Inetpub\wwwroot\phpadmin and then trying to access it from a browser, results in the error message

    The website declined to show this webpage

     HTTP 403
     

    Most likely causes:

    • This website requires you to log in.

     No window requiring a log in appears for the web site.

    All in all, I am more than a little confused. Where should the login window appear? How much configuration should I expect to do?

    Help files are in the documentation provide extensive instructions that are not simple to do, and there seems to be no wizard that will assist.

    So far I have been at it for about three hours with no success.

    mysql connection
    February 17, 2007 by Beth Woodhouse

    I have tried many times and Dreamweaver MX does not connect properly with mysql databases in WinXP SP2 environment (PHP5 and MySQL5).  I get "No Tables Found".  I have seen a similar problem reported and a fix provided for connecting to ASP web pages but cannot find any fix for mysql/php.

    Help please!

    It worked for me :o)
    March 2, 2005 by Tim

    Thanks for this tutorial.

    I had a few questions like "what does that mean" or "now what" but that was to be expected because I was not setting this up on a local machine.   As the tutorial was aimed at a local machine, there is little surprise there.   Also  for some strange reason I could not use phpMyAdmin and had to use Webmin as already installed.

    The part that really helped me was getting DMX to connect.   The followup tutorial was even much more helpful.

    Thanks for a brilliant tutorial 

    See all 7 Comments