-
Jun 2nd, 2011, 04:13 AM
#1
Installing MySQL Server 5.5 on Windows 7
Note: If you're planning to use MySQL with PHP, follow the tutorial Installing PHP 5.3 and Apache HTTP Server on Windows 7 first, if you haven't done so already.
At the time of writing, the latest stable version is 5.5.13.
Installing MySQL
- Get it from here:
http://dev.mysql.com/downloads/mysql/5.5.html
(Don't be fooled! You don't need to create an account. Follow the link "No thanks! Just take me to the downloads.")
Grab the installer — it's much smaller than the zip archive.
You can use either the 32 or 64-bit version. Both will work with a 32-bit PHP.
- Proceed through the wizard, selecting a 'Typical' installation.
You will see a 'MySQL Enterprise' popup at some point. Dismiss it.
- Once the wizard has finished, the MySQL Server Instance Configuration Wizard starts.
- Select 'Detailed Configuration'.
- Select 'Developer Machine'.
- Select 'Multifunctional database'.
- Select a drive.
- Select 'Manual setting', then enter a small number of concurrent connections.
- The default server port is 3306. If you change this, you'll need to specify the port in any applications that connect to the server.
- Select 'Best Support for Multilingualism'. This will set the default character set to UTF-8.
- Select "Include Bin Directory in Windows PATH".
- Enter a password, then finish the wizard.
The settings will be written to a file (my.ini).
If the wizard freezes for more than about 20 seconds at this point, close it and run it again... It's in bin under the directory where you installed MySQL.
- Test the installation by running the MySQL command-line client.
- Create a test database. We'll use this in the next section.
Configuring the MySQL Client
If this is a development machine, you might want to set up your client to log in as 'root' by default. To do this, set up a file called my.cnf and place it in your C:\ directory.
Code:
[client]
user=root
password=PASSWORD
(On Unix platforms, the MySQL client looks in your home directory for this file. Frustratingly, the Windows client does not do this.)
Connecting to MySQL from PHP
- Open the php.ini configuration file in a text editor.
Find the line ; extension_dir = "ext" and change it to:
Code:
extension_dir = "c:\php\ext\"
(If you installed PHP into a different directory, use that path instead.)
- Find the line ;extension=php_pdo_mysql.dll and uncomment it by removing the semicolon.
- Restart the Apache server.
- Copy the following listing into a new file under your htdocs directory.
Code:
<?php
header('Content-type:text/plain');
$dbh = new PDO('mysql:host=localhost;dbname=test', 'root', 'PASSWORD');
$st = $dbh->prepare('select bar from foo');
$st->execute();
var_dump($st->fetch(PDO::FETCH_ASSOC));
?>
- Navigate to that file using your web browser. You should see something like this:
Great success!
Last edited by penagate; Dec 9th, 2011 at 01:44 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|