4.12 Remarques pour Win32

This section describes installation and use of MySQL on Win32. This is also described in the `README' file that comes with the MySQL Win32 distribution.

4.12.1 Installer strong{MySQL} sous Win32

If you don't have a registered version of MySQL, you should first download the shareware version from:

MySQL 3.21.29

If you plan to connect to MySQL from some other program, you will probably also need the MyODBC driver. You can find this at the MySQL download page.

To install either distribution, unzip it in some empty directory and run the Setup.exe program.

Installation takes place in `C:\mysql'.

4.12.2 Démarrer MySQL sous Win95 / Win98

MySQL uses TCP/IP to connect a client to a server. (This will allow any machine on your network to connect to your MySQL server). Because of this, you must install TCP/IP on your machine before starting MySQL. You can find TCP/IP on your Windows CD-ROM.

Note that if you are using an old Win95 release (for example OSR2), it's likely that you have an old Winsock package! MySQL requires Winsock 2! You can get the newest Winsock from Microsoft. Win98 has as default the new Winsock 2 library, so the above doesn't apply for Win98.

There are 2 different MySQL servers you can use:

mysqld Compiled with full debugging and automatic memory allocation checking
mysqld-opt Optimized for a Pentium processor.

Both of the above should work on any Intel processor >= i386.

To start the mysqld server, you should start a MS-DOS window and type:

C:\mysql\bin\mysqld

This will start mysqld in the background without a window.

You can kill the MySQL server by executing:

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

Note that Win95/Win98 don't support creation of named pipes. On Win95/Win98, you can only use named pipes to connect to a remote MySQL running on an NT server.

4.12.3 Démarrer MySQL sous NT

The Win95/Win98 section also applies to MySQL on NT, with the following differences:

To get MySQL to work with TCP/IP, you must install service pack 3 (or newer)!

For NT, the server name is mysqld-nt. Normally you should install MySQL as a service on NT:

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

(You could use the mysqld or mysqld-opt servers on NT, but those cannot be started as a service or use named pipes.)

You can start and stop the MySQL service with:

NET START mysql
NET STOP mysql

Note that in this case you can't use any other options for mysqld-nt!

You can also run mysqld-nt as a standalone program on NT if you need to start mysqld-nt with any options! If you start mysqld-nt without options on NT, mysqld-nt tries to starts itself as a service with the default service options. If you have stopped mysqld-nt, you have to start it with NET START mysql.

The service is installed with the name MySql. Once installed, it must be started using Services Control Manager (SCM) Utility (found in Control Panel) or by using the NET START MySQL command. If any options are desired, they must be specified as "Startup parameters" in the SCM utility before you start the MySQL service. Once running, mysqld-nt can be stopped using mysqladmin or from the SCM utility or by using the command NET STOP MySQL. If you use SCM to stop mysqld-nt, there is a strange message from SCM about mysqld shutdown normally. When run as a service, mysqld-nt has no access to a console and so no messages can be seen.

On NT you can get the following service error messages:

Permission Denied Means that it cannot find mysqld-nt.exe
Cannot Register Means that the path is incorrect

If you have problems installing mysqld-nt as a service, try starting it with the full path:

C:\mysql\bin\mysqld --install

If this doesn't work, you can get mysqld-nt to start properly by fixing the path in the registry!

If you don't want to start mysqld-nt as a service, you can start it as follows:

C:\mysql\bin\mysqld-nt --standalone

or

C:\mysql\bin\mysqld-nt --standalone --debug

The last version gives you a debug trace in `C:\mysqld.trace'.

4.12.4 Faire tourner MySQL sous Win32

MySQL supports TCP/IP on all Win32 platforms and named pipes on NT. The default is to use named pipes for local connections on NT and TCP/IP for all other cases if the client has TCP/IP installed. The host name specifies which protocol is used:

Host name
protocol
NULL (none) On NT, try named pipes first; if that doesn't work, use TCP/IP. On Win95/Win98, TCP/IP is used.
. Named pipes
localhost TCP/IP to current host
hostname TCP/IP

You can force a MySQL client to use named pipes by specifying the --pipe option. Use the --socket option to specify the name of the pipe.

You can test whether or not MySQL is working by executing the following commands:

C:\mysql\bin\mysqlshow
C:\mysql\bin\mysqlshow -u root mysql
C:\mysql\bin\mysqladmin version status proc
C:\mysql\bin\mysql test

By default, MySQL-Win32 is configured to be installed in `C:\mysql'. If you want to install MySQL elsewhere, install it in `C:\mysql', then move the installation to where you want it. If you do move MySQL, you must tell mysqld where everything is by supplying options to mysqld. Use C:\mysql\bin\mysqld --help to display all options! If, for example, you have moved the MySQL distribution to `D:\programs\mysql', you must start mysqld with: D:\programs\mysql\bin\mysqld --basedir D:\programs\mysql

With the registered version of MySQL, you can also create a `C:\my.cnf' file that holds any default options for the MySQL server. Copy the file `\mysql\my-example.cnf' to `C:\my.cnf' and edit this to suit your setup. Note that you should specify all paths with / instead of \. If you use \, you need to specify this twice, as \ is the escape character in MySQL. 4.15.4 Fichier d'options.

If mysqld is slow to answer to connections on Win95/Win98, there is probably a problem with your DNS. In this case, start mysqld with --skip-name-resolve and use only localhost and IP numbers in the MySQL grant tables. You can also avoid DNS when connecting to a mysqld-nt MySQL server running on NT by using the --pipe argument to specify use of named pipes. This works for most MySQL clients.

There are two versions of the MySQL command line tool:
mysql Compiled on native Win32, which offers very limited text editing capabilities.
mysqlc Compiled with the Cygnus GNU compiler and libraries, which offers readline editing.

If you want to use mysqlc.exe, you must copy `C:\mysql\lib\cygwinb19.dll' to `\windows\system' (or similar place).

The default privileges on Win32 give all local users full privileges to all databases. To make MySQL more secure, you should set a password for all users and remove the row in the mysql.user table that has Host='localhost' and User=''.

You should also add a password for the root user:

C:\mysql\bin\mysql mysql
mysql> DELETE FROM user WHERE Host='localhost' AND User='';
mysql> QUIT
C:\mysql\bin\mysqladmin reload
C:\mysql\bin\mysqladmin -u root password your_password

After you've set the password, if you want to take down the mysqld server, you can do so using this command:

mysqladmin --user=root --password=your_password shutdown

4.12.5 Se connecter à un serveur lointain MySQL avec Win32 et SSH

Here is a note about how to connect to get a secure connection to remote MySQL server with SSH (by David Carlson).

That's it. It works very well with a direct Internet connection. I'm having problems with SSH conflicting with my Win95 network and Wingate - but that'll be the topic of a posting on another software company's usegroup!

4.12.6 MySQL-Win32 comparé à Unix MySQL

MySQL-Win32 has by now proven itself to be very stable. This version of MySQL has the same features as the corresponding Unix version with the following exceptions:

Win95 and threads
Win95 leaks about 200 bytes of main memory for each thread creation. Because of this, you shouldn't run mysqld for an extended time on Win95 if you do many connections, since each connection in MySQL creates a new thread! WinNT and Win98 don't suffer from this bug.
Blocking read
MySQL uses a blocking read for each connection. This means that:
  • A connection will not be disconnected automatically after 8 hours, as happens with the Unix version of MySQL.
  • If a connection ``hangs,'' it's impossible to break it without killing MySQL.
  • mysqladmin kill will not work on a sleeping connection.
  • mysqladmin shutdown can't abort as long as there are sleeping connections.
We plan to fix this in the near future.
UDF functions
For the moment, MySQL-Win32 does not support user definable functions.
DROP DATABASE
You can't drop a database that is in use by some thread.
Killing MySQL from the task manager
You can't kill MySQL from the task manager or with the shutdown utility in Windows95. You must take it down with mysqladmin shutdown.
Case-insensitive names
Filenames are case insensitive on Win32, so database and table names are also case insensitive in MySQL for Win32. The only restriction is that database and table names must be given in the same case throughout a given statement. The following query would not work because it refers to a table both as my_table and as MY_TABLE:
SELECT * FROM my_table WHERE MY_TABLE.col=1;
The `\' directory character
Pathname components in Win95 are separated by `\' characters, which is also the escape character in MySQL. If you are using LOAD DATA INFILE or SELECT ... INTO OUTFILE, you must double the `\' character or use Unix style filenames `/' characters:
LOAD DATA INFILE "C:\\tmp\\skr.txt" INTO TABLE skr;
SELECT * FROM skr INTO OUTFILE 'C:/tmp/skr.txt';
Can't open named pipe error
If you use the shareware version of MySQL-Win32 on NT with the newest mysql-clients you will get the following error:
error 2017: can't open named pipe to host: . pipe...
This is because the release version of MySQL uses named pipes on NT by default. You can avoid this error by using the --host=localhost option to the new MySQL clients or create a file `C:\my.cnf' that contains the following information:
[client]
host = localhost
Access denied for user error
If you get the error Access denied for user: 'some-user@unknown' to database 'mysql' when accessing a MySQL server on the same machine, this means that MySQL can't resolve your host name properly. To fix this, you should create a file `\windows\hosts' with the following information:
127.0.0.1       localhost

Here are some open issues for anyone who might want to help us with the Win32 release:

  • Make a single user MYSQL.DLL server. This should include everything in a standard MySQL server, except thread creation. This will make MySQL much easier to use in applications that don't need a true client/server and don't need to access the server from other hosts.
  • Add some nice ``start'' and ``shutdown'' icons to the MySQL installation.
  • Create a tool to manage registry entries for the MySQL startup options. The registry entry reading is already coded into mysqld.cc, but it should be recoded to be more ``parameter'' oriented. The tool should also be able to update the `\my.cnf' file if the user would prefer to use this instead of the registry.
  • When registering mysqld as a service with --install (on NT) it would be nice if you could also add default options on the command line. For the moment, the workaround is to update the `C:\my.cnf' file instead.
  • When you suspend a laptop running Win95, the mysqld daemon doesn't accept new connections when the laptop is resumed. We don't know if this is a problem with Win95, TCP/IP or MySQL.
  • It would be real nice to be able to kill mysqld from the task manager. For the moment, you must use mysqladmin shutdown.
  • Port readline to Win32 for use in the mysql command line tool.
  • GUI versions of the standard MySQL clients (mysql, mysqlshow, mysqladmin, and mysqldump) would be nice.
  • It would be nice if the socket ``read'' and ``write'' functions in `net.c' were interruptible. This would make it possible to kill open threads with mysqladmin kill on Win32.
  • Documentation of which Windows programs work with MySQL-Win32/MyODBC and what must be done to get them working.
  • mysqld always starts in the "C" locale and not in the default locale. We would like to have mysqld use the current locale for the sort order.
  • Port sqlclient to Win32 (almost done) and add more features to it!
  • Add more options to MysqlManager.
  • Change the communication protocol between the server and client to use Windows internal communication instead of sockets and TCP/IP.
  • Implement UDF functions with .DLLs.
  • Add macros to use the faster thread-safe increment/decrement méthodes provided by Win32.

Other Win32-specific issues are described in the `README' file that comes with the MySQL-Win32 distribution.