Вы находитесь на странице: 1из 3

Installing MYSQL: Next we will be installing MySQL version 5. Follow the steps carefully. 1. Go to www.mysql.

com and download the "Windows (x86) ZIP/Setup.EXE (version 5.0.27)" to your desktop. (To do this you'll need to register an account with MySQL.) 2. Once "mysql-5.0.27-win32.zip" has finished downloading, you can extract it using WinZIP or a similiar program. 3. Once extracted, double click on the "Setup.exe" file. An installation wizard will appear.

7. The next screen will tell you that the installation wizard is complete. Make sure that the "Configure the MySQL Server now" field is checked before clicking "Finish".

8. The MySQL Server Instance Configuration Wizard should appear. Click "Next". 9. Select "Detailed Configuration" and click "Next". 10. Select "Developer Machine" and click "Next". 11. Select "Multifunctional Database" and click "Next". 12. Click "Next". Click "Next". 4. Select "Typical" Installation and click "Next". 5. Click "Install". (Be patient, this can take up to several minutes). 6. The next screen will ask you to "Sign Up". Select "Skip SignUp" for now. 13. Select "Decision Support (DSS)/OLAP" and click "Next". 14. Select "Multifunctional Database" and click "Next". 15. Make sure "Enable TCP/IP Networking" is checked, the Port Number is set to "3306", and "Enable Strict Mode" is checked. Click "Next". 16. Select "Standard Character Set" and click "Next".

17. Check "Install As Windows Service", set the Service Name to "MySQL", and check "Launch the MySQL Server automatically". Make sure that the "Include Bin Directory in Windows Path" is NOT checked. Click "Next". 18. On the next screen, check the box that says "Modify Security Settings". Enter a password for the default "root" account, and confirm the password in the box below. Do NOT check the boxes "Enable root access from remote machines" or "Create An Anonymous Account". Click "Next". 19. Click "Execute". (This may take a few minutes. Be patient). 20. Click "Finish". 21. To test if MySQL was installed correct, go to: Start > All Programs > MySQL > MySQL Server 5.0 > MySQL Command Line Client. The MySQL Command Line Client will appear: If you don't get any errors, and it returns the information shown above, then MySQL has been successfully installed! Next we will need to configure PHP to work with MySQL. Configuring PHP to work with MySQL: Now that both PHP and MySQL are installed, we have to configure them to work together. 1. Open up your php.ini file (C:/WINDOWS/php.ini) and find the line: ;extension=php_mysql.dll To enable the MySQL extension, delete the semi-colon at the beginning of that line. 2. Next we must add the PHP directory to the Windows PATH. To do this, click: Start > My Computer > Properties > Advanced > Environment Variables. Under the second list (System Variables), there will be a variable called "Path". Select it and click "Edit". Add ";C:\php" to the very end of the string and click "OK". 3. Restart your computer for the changes to take effect.

22. It will ask you for a password. Enter the password you created in step 18. (If you enter an incorrect password MySQL will automatically close the command line) 23. Next, type in the commands shown below: (shown in blue)

4. Create a new file in your "htdocs" directory called "mysql_test.php". 5. Copy the following code into "mysql_test.php" and click save. (Make sure to replace the MYSQL_PASS constant with the MySQL Password you specified during the MySQL installation). <?php # Define MySQL Settings define("MYSQL_HOST", "localhost"); define("MYSQL_USER", "root"); define("MYSQL_PASS", "password"); define("MYSQL_DB", "test"); $conn = mysql_connect("".MYSQL_HOST."", "".MYSQL_USER."", "".MYSQL_PASS."") or die(mysql_error()); mysql_select_db("".MYSQL_DB."",$conn) or die(mysql_error()); $sql = "SELECT * FROM test"; $res = mysql_query($sql); while ($field = mysql_fetch_array($res)) { $id = $field['id']; $name = $field['name']; echo 'ID: ' . $field['id'] . '<br />'; echo 'Name: ' . $field['name'] . '<br /><br />'; } ?> 6. Open up Internet Explorer and type in "http://localhost/mysql_test.php". If the "mysql_test.php" page returns something similiar to: ID: 1 Name: John Then PHP & MySQL have been successfully configured to work together. Congratulations! The next and final step is to install phpMyAdmin.

Вам также может понравиться