In Windows, you may encounter some errors during the first installation and running of MySQL, so that the MySQL server cannot be started. This section aims to help you diagnose and correct these errors.
When solving server problems, your first data is error logs. The MySQL server uses error logs to record the information that the server cannot start. The error log is located in the data directory specified by the my. ini file. The default data directory is in C: Program FilesMySQLMySQL Server 5.1dat.
Another error-related information source is the message displayed on the console when the MySQL service is started. After installing mysqld as a service, run the net start mysql command on the command line to view the error messages related to MySQL service startup.
The following describes the most common error messages that MySQL will encounter when it is installed and started for the first time:
? System error 1067 has occurred.
? Fatal error: Can't open privilege tables: Table 'MySQL. host' doesn' t exist
? The message is displayed when the MySQL server cannot find the MySQL permission database or key files. This problem is often encountered when the MySQL base or data directory is not installed in the default location (C: mysql and C: Program FilesMySQLMySQL Server 5.1 data.
This problem occurs when MySQL is upgraded or installed to a new location, but the configuration file is not updated to match the new installation location. In addition, the old and new configuration files may conflict. when upgrading MySQL, you must delete or rename the old configuration file.
If you have not installed MySQL to the C: Program FilesMySQLMySQL Server 5.1 directory, but to other directories, you need to use the configuration (my. ini) file to let the MySQL server know the installation directory. The my. ini file should be located in the Windows directory, typically C: WINNT or C: WINDOWS. You can enter the following command at the command prompt to determine the exact position from the WINDIR environment variable value:
C:> echo % WINDIR % you can use a text editor (such as Notepad) to create and modify the option file. For example, if MySQL is installed in E: mysql and the data directory is in D: MySQLdata, you can create an option file and set [mysqld] to specify the value of the basedir and datadir parameters:
[Mysqld]
# Set basedir to your installation path
Basedir = E:/mysql
# Set datadir to the location of your data directory
Datadir = D:/MySQLdata
Note that you should use a forward slash instead of a backslash to specify the Windows path name in the option file. If a backslash is used, the double slash must be used:
[Mysqld]
# Set basedir to your installation path
Basedir = C: Program FilesMySQLMySQL Server 5.1
# Set datadir to the location of your data directory
Datadir = D: MySQLdata
If you change the datadir value in the MySQL configuration file, you must move the content in the existing MySQL data directory before restarting the MySQL server.
? Error: Cannot create Windows service for MySql. Error: 0
? This problem occurs when you have not stopped and uninstalled an existing MySQL service and re-installed or upgraded MySQL using the MySQL Configuration Wizard. The reason is that when the Configuration Wizard tries to install the service, it finds that a service with the same name already exists.
One solution to this problem is to use the configuration wizard to select a service name other than mysql. In this way, the new service can be correctly installed, but the original service is retained. But this is not good. it is best to unload old services that are no longer in use.
To permanently uninstall the old MySQL service, you can run the following command on the command line through the management permission:
C:> SC delete mysql
[SC] DeleteService SUCCESS
If the SC tool is not available in Windows, you can download the delsrv tool and use the delsrvMySQL syntax.