Hi-Fi優質I.T網:MySQL ?嚙踝???forum_id=49-討論區
您尚未登入...
帳號:
密碼:

忘記密碼 
 
  訂閱電子報

取消   訂閱
 
討論區>>MySQL ?嚙踝???forum_id=49<<

 
 
發起人:
admin
中級會員
張貼時間:2005/12/18-11:56:32
   檢舉

 主題:Starting MySQL as a Windows Service For MySQL 5.1

Before installing MySQL as a Windows service, you should first stop the current server if it is running by using the following command:

C:\> C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqladmin -u root shutdown

Note: If the MySQL root user account has a password, then you need to invoke this command as C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqladmin -u root -p shutdown and supply the password when prompted.

This invokes the MySQL administrative utility mysqladmin, which connects to the server and tells it to shut down. The command connects as the MySQL root user, which is the default administrative account in the MySQL grant system. Note that users in the MySQL grant system are wholly independent from any login users under Windows.

Install the server as a service using this command:

C:\> mysqld --install

If you have problems installing mysqld as a service using just the server name, try installing it using its full pathname. For example:

C:\> C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld --install

You can also add the path to the mysql bin directory to your Windows system PATH environment variable:

On the Windows desktop, right-click on the My Computer icon, and select Properties

Next select, the Advanced tab from the System Properties menu that appears, and click the Environment Variables button.

Under System Variables, select Path , and then click the Edit button. The Edit System Variable dialogue should appear.

Place your cursor at the end of the text appearing in the space marked Variable Value. (Use the End key to ensure that your cursor is positioned at the very end of the text in this space.) Then enter the complete path to your MySQL bin directory (for example, C:\Program Files\MySQL\MySQL Server 5.1\bin), Note that there should be a semicolon separating this path from any values present in this field. Dismiss this dialogue, and each dialogue in turn, by clicking OK until all of the dialogues that were opened have been dismissed. You should now be able to invoke any MySQL executable program by typing its name at the DOS prompt from any directory on the system, without having to supply the path. This includes the servers, the mysql client, and all MySQL command-line utilities such as mysqladmin and mysqldump.

Note that you should not add the MySQL bin directory to your Windows PATH if you are running multiple MySQL servers on the same machine.

Warning: You must exercise great care when editing your system PATH by hand; the accidentally deletion or modification of any portion of the existing PATH value can leave you with a malfunctioning or even unusable system.

The service-installation command does not start the server. Instructions for that are given later in this section.

The following additional arguments are available in MySQL 5.1 when installing the service:

You can specify a service name immediately following the --install option. The default service name is MySQL.

If a service name is given, it can be followed by a single option. By convention, this should be --defaults-file=file_name to specify the name of an option file from which the server should read options when it starts.

It is possible to use a single option other than --defaults-file, but this is discouraged. --defaults-file is more flexible because it enables you to specify multiple startup options for the server by placing them in the named option file.

You can also specify a --local-service option following the service name. This causes the server to run using the LocalService Windows account that has limited system privileges. This account is available only for Windows XP or newer. If both --defaults-file and --local-service are given following the service name, they can be in any order.

For a MySQL server that is installed as a Windows service, the following rules determine the service name and option files that the server uses:

If the service-installation command specifies no service name or the default service name (MySQL) following the --install option, the server uses the a service name of MySQL and reads options from the [mysqld] group in the standard option files.

If the service-installation command specifies a service name other than MySQL following the --install option, the server uses that service name. It reads options from the group that has the same name as the service, and reads options from the standard option files.

The server also reads options from the [mysqld] group from the standard option files. This allows you to use the [mysqld] group for options that should be used by all MySQL services, and an option group with the same name as a service for use by the server installed with that service name.

If the service-installation command specifies a --defaults-file option after the service name, the server reads options only from the [mysqld] group of the named file and ignores the standard option files.

As a more complex example, consider the following command:

C:\> C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld --install MySQL --defaults-file=C:\my-opts.cnf

Here, the default service name (MySQL) is given after the --install option. If no --defaults-file option had been given, this command would have the effect of causing the server to read the [mysqld] group from the standard option files. However, because the --defaults-file option is present, the server reads options from the [mysqld] option group, but only from the named file.

You can also specify options as Start parameters in the Windows Services utility before you start the MySQL service.

Once a MySQL server has been installed as a service, Windows starts the service automatically whenever Windows starts. The service also can be started immediately from the Services utility, or by using the command NET START MySQL. The NET command is not case sensitive.

When run as a service, mysqld has no access to a console window, so no messages can be seen there. If mysqld does not start, check the error log to see whether the server wrote any messages there to indicate the cause of the problem. The error log is located in the MySQL data directory (for example, C:\Program Files\MySQL\MySQL Server 5.1\data). It is the file with a suffix of .err.

When a MySQL server has been installed as a service, and the service is running, Windows stops the service automatically when Windows shuts down. The server also can be stopped manually by using the Services utility, the command NET STOP MySQL, or the command mysqladmin shutdown.

You also have the choice of installing the server as a manual service if you do not wish for the service to be started automatically during the boot process. To do this, use the --install-manual option rather than the --install option:

C:\> C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld --install-manual

To remove a server that is installed as a service, first stop it if it is running by executing NET STOP MYSQL. Then use the --remove option to remove it:

C:\> C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld --remove

簽名
-===== 路是人走出來的=====-

 



 

Hi-Fi優質I.T網”站內所有文章、圖片除特別加註外均屬本站所有,如有任何問題請來信告知
請支持言論自由,討論區所發表之言論不代表本站立場
Hi-Fi優質I.T網”版權所有2004©
---最佳顯示效果1024*768---