Under Linux, the MySQL service starts and shuts down:
The correct way is to go into the MySQL bin directory and then execute
./mysqladmin-uroot-p shutdown
Then enter your password to do so.
If your root does not have a password, you do not need the-p option.
The correct way to start is: Go to the MySQL bin directory and nohup./mysqld_safe &.
Start and stop the MySQL service
1. Start the MySQL service
The command to start the MySQL service is:
/etc/init.d/mysqld start
The command executes after 7-5, indicating that the MySQL service started successfully.
(Click to view larger image) Figure 7-5 start the MySQL service
You can also start the MySQL service with/etc/init.d/mysqld's simplified commands:
Service mysqld Start
The command executes as shown in result 7-6.
(Click to view larger image) Figure 7-6 Service command to start MySQL services
2. Stop the MySQL service
The commands to stop the MySQL service are:
W/etc/init.d/mysqld stop
The command executes after 7-7, indicating that the MySQL service was stopped successfully.
(Click to view larger image) Figure 7-7 Stop MySQL Service
You can also stop the MySQL service with service commands. As shown in 7-8.
(Click to view larger image) Figure 7-8 Service command stop MySQL Services
3. Restart the MySQL service
The command to restart the MySQL service is:
/etc/init.d/mysqld restart
The command executes after 7-9, indicating a successful restart of the MySQL service.
(Click to view larger image) Figure 7-9 restarting the MySQL service
You can also stop the MySQL service with service commands. As shown in 7-10.
(Click to view larger image) Figure 7-10 Service command to restart MySQL services
4. Start the MySQL service automatically
If you need to have the MySQL service automatically load with the system boot, you can execute the "NTSYSV" Command automatic service configuration program, find the "mysqld" service, press the SPACEBAR to precede it with "*" asterisk, and then press the TAB key, select "OK", 7-11.
(Click to view larger image) Figure 7-11 set the MySQL service to run automatically
or reboot directly
$mysql _dir/bin/mysqladmin-u root-p shutdown
$mysql _dir/bin/safe_mysqld &
Linux mysqld start-up process