3/16/2009

    Setting up MySQL

    Installation

    The MySQL installation is pretty straightforward since you doesn't need to modify anything in the Apache or PHP configuration. To begin the installation, run the setup program and select the destination folder if you don't want to use the default one. Then choose Custom and deselect Examples, Libraries, Includes and Script files. You can deselect also the MySQL Documentation if you already have it.


    Press Next for starting the installation. After it finish, you need to install the MySQL service, since the setup program of versions 4.0.x doesn't install it. Fortunately, the MySQL package includes an utility that simplifies greatly this task.

    First you need go to the MySQL installation folder, as the setup doesn't create either any shortcuts in the Start Menu (don't ask me why). In the "bin" subfolder locate the file winmysqladmin.exe and execute it. The first time this tool is executed, it'll ask you for an user name & password, enter the one you want to use. You don't need this user & password for your scripts, but the tool use it for polling the server status and display detailed information about it.

    After pressing OK the tool will create a new configuration file for the MySQL server in the Windows folder (my.ini), and a semaphore icon will appear in the taskbar. Also, the program will install the MySQL service using the values of the configuration file. If the semaphore shows the red light on, right click on that icon and select Win NT -> ShuDown this tool for closing the program, and then launch it again (with some system configurations it doesn't install the service in the first run). This time it should show the green light on, indicating that the MySQL service is installed an running. The tool will create also a shortcut for it in the Start folder of the Start Menu.

    Note for Windows 98/Me users: Since these OS doesn't support services, you need to run mysqld.exe for starting the server. To close the server, press Ctrl+C on the MySQL console window.
    Installing phpMyAdmin

    phpMyAdmin is a very popular tool for managing the MySQL server and the databases. Since it's a PHP based application, installing it is as simple as unpacking the ZIP file in a folder inside the document root of Apache (note that the ZIP file already contains a folder). To access the application open your browser and navigate to that folder: supposing that your web root is "D:\Web server" and the folder in which you stored the script files is "D:\Web server\phpMyAdmin", you need to go to "http://localhost/phpMyAdmin/".

    If both Apache & MySQL servers are running, you should see the welcome screen without any further configuration, since phpMyAdmin is preconfigured to use the default configuration of MySQL.

    A few notes about MySQL users

    * By default, MySQL 4.0.x comes with the predefined user "root" with no password. You can use this user for the mysql_connect() function.
    * If you want or need to create another user for your scripts, you can do it from phpMyAdmin using the Privileges section. You can also add a password for the root user, but if you modify it you need to update the phpMyAdmin configuration. For doing that, go to the phpMyAdmin folder, locate the file config.default.php and copy it as config.inc.php. Then find following lines:

    $cfg['Servers'][$i]['user'] = 'root'; // MySQL user
    $cfg['Servers'][$i]['password'] = ''; // MySQL password
    and modify the last values with the new user & password. You can use here any other user you have created with admininstrator privileges.

    0 comments:

    Post a Comment