Operators


Installing MySQL on Windows

You can run MySQL on NT-based systems such as Windows NT, 2000, XP, and 2003, or on non-NT systems such as Windows 95, 98, and Me. To do so, you must have TCP/IP support installed. On Windows NT 4, make sure that your system is at service pack 3 or later. On Windows 95, make sure that your Winsock software is at least version 2.

I recommend that you use an NT-based version of Windows if possible. Then you'll have the option of running the MySQL server as a service that Windows starts and stops automatically at system startup and shutdown time. The NT-specific MySQL servers (mysqld-nt and mysqld-max-nt) also support the option of allowing clients to connect using a named pipe.

In addition to the MySQL server and client programs, you might also want to install Connector/ODBC, the MySQL driver for the ODBC (Open Database Connectivity) standard developed by Microsoft. Connector/ODBC allows ODBC-compliant programs to access MySQL databases. For example, you can install Connector/ODBC and then use ODBC programs such as Microsoft Access to connect to a MySQL server.

As of MySQL 4.1.5, there are three distribution types to choose from on Windows:

  • The Noinstall package is a Zip archive containing all components needed for a MySQL installation. A Noinstall package has a filename that begins with mysql-noinstall. You simply unpack the archive to produce a folder, and then move the folder to where you want MySQL to be installed. For example, unpacking a distribution named mysql-noinstall-4.1.9-win32.zip produces a folder named mysql-noinstall-4.1.9-win32. If you want to install MySQL at C:\mysql, rename the folder to mysql and then move it to the root directory on the C: drive.

  • The Complete package contains a Configuration Wizard and all components needed for a MySQL installation. A Complete package has a filename of the form mysql-version-win32.zip. To install a Complete package, download it, launch the Setup.exe program that it contains, and then follow the instructions in the dialogs that it presents.

  • The Essentials package is similar to the Complete package, but contains only a minimal set of files needed for a MySQL installation. For example, it omits the debugging version of the MySQL server. An Essentials package has a filename that begins with mysql.essential. To install an Essentials package, download it, launch it, and then follow the instructions in the dialogs that it presents.

The Complete and Essentials package installers like to put MySQL under C:\Program Files\MySQL rather than at C:\mysql. They also create a Start Menu entry and a key in the Windows registry, which the Noinstall package does not.

Note: The Configuration Wizard included with the Complete and Essentials packages can upgrade a previous installation of MySQL automatically, but this capability has certain limitations:

  • It can upgrade only existing MySQL installations from 4.1.5 or later. If the existing version of MySQL is older than 4.1.5, the Configuration Wizard might remove it.

  • The Configuration Wizard can update only from one 4.1 version to another, or from one 5.0 version to another. It cannot update a 4.1 version to a 5.0 version.

Due to these limitations, if you're upgrading an existing MySQL installation, it's best to make a backup of your databases before installing a new version.

For additional information about installing MySQL on Windows, see the installation chapter in the MySQL Reference Manual.

If you want to be able to invoke MySQL programs from the command line without typing their full pathnames, set your PATH environment variable to include the bin directory under the location where MySQL is installed. For example, if you install MySQL in C:\mysql, add C:\mysql\bin to your path. You can set your path in the AUTOEXEC.BAT file or (on NT-based systems) by using the System item in the Control Panel. You might need to restart Windows for the change to take effect.

After installing MySQL on Windows, it is not necessary to initialize the data directory or the grant tables because they are included pre-initialized in the distribution. However, if you install MySQL in any place other than the default location selected by the installer, you must place a [mysqld] option group in an option file that the server reads when it starts, so that it can determine where the installation base directory and the data directory are located. The option file can be either the my.ini file in your Windows directory or C:\my.cnf. For example, if you install MySQL in E:\mysql, the option group should look like this (note the use of forward slashes in the pathnames rather than backslashes):

 [mysqld] basedir=E:/mysql datadir=E:/mysql/data 

The following instructions assume that you install MySQL in C:\mysql. If you select a different installation directory, you'll need to change the pathnames in the commands shown in the examples.

On Windows, you can choose from the MySQL server programs shown in the following table. (The Essentials package includes only the mysqld and mysqld-nt servers.)

Server

Description

mysqld

Optimized server that supports InnoDB

mysqld-debug

Server that supports InnoDB, BDB, and debugging

mysqld-nt

Optimized server that supports InnoDB and named pipes

mysqld-max

Optimized server that supports InnoDB and BDB

mysqld-max-nt

Like mysqld-max but with named pipe support


In general, unless you need the debugging support provided by the mysqld-debug server, you are better off choosing one of the other servers. The mysqld-debug server uses much more memory and runs more slowly than the other Windows servers.

The servers with -nt in their name support connections over named pipes when run on NT-based systems. However, named pipe support is disabled by default. To use this capability, you must add a line to the [mysqld] group in your option file:

 [mysqld] enable-named-pipe 

On Windows NT-based systems, any MySQL server can be installed to run as a service that starts automatically whenever Windows starts. For example, to install the mysqld-nt server as a Windows service, use this command:

 C:\> C:\mysql\bin\mysqld-nt --install 

If you use --install-manual rather than --install, the server is installed as a Windows service, but does not run automatically when Windows starts. You must use the Windows Services Manager or the net start command.

If you install a MySQL server as a Windows service, you can specify other options by putting them in the [mysqld] group of an option file.

For a server that is installed as a service, you can start it manually using the Windows Services Manager. You should be able to find this as a Services item in the Windows Control Panel or in the Administrative Tools item in the Control Panel. The service also can be started using the following command:

 C:\> net start MySQL 

To stop the server, use the Services Manager or one of the following commands:

 C:\> net stop MySQL C:\> C:\mysql\bin\mysqladmin -u root shutdown 

To remove MySQL as a service, shut down the server if it is running, and then invoke this command:

 C:\> C:\mysql\bin\mysqld-nt --remove 

To avoid interactions between the Services Manager and commands issued from the command prompt, it is best to close the Services Manager whenever you invoke service-related commands from the prompt.

On non-NT-based systems (or on NT systems if you do not install the server as a service), you must start and stop the server manually from the command line. For example, to run mysqld-max, start it as follows:

 C:\> C:\mysql\bin\mysqld-max 

You can specify other options on the command line if you want. To shut down the server, use mysqladmin:

 C:\> C:\mysql\bin\mysqladmin -u root shutdown 

To run a server in console mode so that it displays error messages in a console window, invoke it with the --console option. For example, to run mysqld this way, use the following command:

 C:\> C:\mysql\bin\mysqld --console 

When you run a MySQL server in console mode, you can specify other options on the command line after the --console option or in an option file. To shut down the server, use mysqladmin.

Note: When you run a MySQL server from the command line, you will not necessarily see another command prompt until the server exits. If this occurs, just open another console window in which to run MySQL client programs.

If you have problems getting the server to run, check the Windows notes in the installation chapter in the MySQL Reference Manual.

If you are installing MySQL for the first time on this machine, there are other actions that you'll probably want to perform at this point:

  • The default installation allows anyone to use the MySQL root accounts without a password. For security reasons, it's a good idea to assign passwords to them.

  • You can arrange for the server to start and stop automatically as part of your system's normal startup and shutdown procedures.

  • You can put the --user option in an option file to avoid having to specify it each time you start the server.

  • Various kinds of logging can be enabled. These are useful for monitoring the server, for replication, and for data recovery procedures.

  • You can enable or disable storage engines, or specify tuning parameters for them.

Instructions for performing these actions are given in Chapter 11.

Current distributions of MySQL for Windows include the server-side help tables used for the help command of the mysql client. It should not be necessary to set up the help tables manually. However, the time zone tables that are needed for named time zone support may be missing or empty. To set up these tables, use the instructions in "Configuring Time Zone Support," in Chapter 11.

If you are upgrading a MySQL installation, it is possible that the grant table structure has changed since your original installation. To update the tables to the current structure, use the instructions in "Dealing with Changes to Grant Table Structure," in Chapter 11.

Installing Perl DBI Support on Windows

The easiest way to install Perl modules under Windows is to get the ActiveState Perl distribution from www.activestate.com and install it. Then fetch and install the additional Perl modules that you need. The ppm (Perl Package Manager) program is used for this.

 C:\> ppm ppm> install DBI ppm> install DBD-mysql ppm> install CGI 

Installing Apache and PHP on Windows

Apache and PHP are available as Windows binaries from the Apache and PHP Web sites listed near the beginning of this appendix. Under Apache 1.3.x, PHP may be run only as a standalone CGI program. Under Apache 2.x, you can run PHP either as a standalone program or as an Apache module.

The PHP 5 binary distributions for Windows do not include MySQL support, so I recommend that you use the latest PHP 4 distribution. The Zip file distribution includes a go-pear program. Executing it installs the pear program that can be used to install and update PEAR modules, including the DB module. See the section "Installing Apache and PHP on Unix" earlier in this appendix for some notes on using pear.

Installing Connector/ODBC on Windows

Current distributions of Connector/ODBC 3 are packaged as executable files with filenames of the form MyODBC-version-win.exe or MyODBC-version-win.msi. If you encounter an error such as "Problems while copying MFC30.DLL," while installing Connector/ODBC, MFC30.DLL is being used by some application. In this case, try selecting the Ignore option that is presented with the error message. MySQL should finish installing and most likely will work despite the error. If it doesn't, try restarting Windows in safe mode and running the installer again.

After installing a Connector/ODBC distribution, configure the driver using the ODBC item in the Control Panel. (It should be located in the Control Panel or in the Administrative Tools item in the Control Panel, with a name such as "Data Sources (ODBC)" or "ODBC Data Sources.") When you run the ODBC item, you'll see a window that allows you to set up a data source name (DSN). Click the User DSN tab and then click the Add button to bring up a window that lists the available data source drivers. Select the MySQL driver from the list of sources and click the Finish button. Another window will appear that allows you to enter connection parameters for the data source. Fill in parameters that are appropriate for the connection that you want to establish, and then click the OK button. The following example shows how to fill in the fields to set up a data source for connecting to the local server to access the sampdb database with a username and password of sampadm and secret:

Field Name

Field Value

Data Source Name:

sampdb-dsn

Host/Server Name (or IP):

localhost

Database Name:

sampdb

User:

sampadm

Password:

secret

Port:

3306


After configuring Connector/ODBC, you should be able to use ODBC-aware programs to access MySQL databases. For example, one common use for Connector/ODBC is to connect to a MySQL server from Microsoft Access. After ODBC has been set up, use the following steps to connect to the MySQL server from within Access. Note that the tables you want to use must already exist before you can link to them.

1.

Start the Access program.

2.

Open your database or create a new database.

3.

From the File menu, select Get External Data, and then select Link Tables.

4.

In the window that appears, click on the Files of type popup menu and select ODBC Databases.

5.

Select the DSN that you configured in the Control Panel ODBC item for connecting to MySQL.

6.

Select the MySQL tables you want to use.

After performing this procedure, the selected tables will be available through Access.



MySQL The definitive guide to using, programming, and administering MySQL 4. 1 and 5. 0
Mysql: the Definitive Guide to Using, Programming, and Administering Mysql 4.1 and 5.0
ISBN: B003A1PKHY
EAN: N/A
Year: 2004
Pages: 190
Authors: Paul Dubois

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net