linux下mysql启动的方法有几种(windows和mac下启动比较方便):
mysqld — The MySQL Server mysqld_safe — MySQL Server Startup Script mysql.server — MySQL Server Startup Script mysqld_multi — Manage Multiple MySQL Servers
当然还有通过service来起mysql server的。默认安装后会注册为service的,所以再重启机器后也mysql server也启动了的。这就能解释为什么机器重启后mysql client还能连接。
service mysqld start service mysqld stop service mysqld restart
这4种命令又有什么区别呢?什么情况下使用哪个命令?
shell> mysql.server start shell> mysql.server stop Before mysql.server starts the server, it changes location to the MySQL installation directory, and then invokes mysqld_safe. To run the server as some specific user, add an appropriate user option to the [mysqld] group of the /etc/my.cnf option file, as shown later in this section. (It is possible that you must edit mysql.server if you've installed a binary distribution of MySQL in a nonstandard location. Modify it to change location into the proper directory before it runs mysqld_safe. If you do this, your modified version of mysql.server may be overwritten if you upgrade MySQL in the future, so you should make a copy of your edited version that you can reinstall.) mysql.server stop stops the server by sending a signal to it. You can also stop the server manually by executing mysqladmin shutdown. To start and stop MySQL automatically on your server, you must add start and stop commands to the appropriate places in your /etc/rc* files.
mysqld_safe Options Format Description --basedir Path to MySQL installation directory --core-file-size Size of core file that mysqld should be able to create --datadir Path to data directory --defaults-extra-file Read named option file in addition to usual option files --defaults-file Read only named option file --help Display help message and exit --ledir Path to directory where server is located --log-error Write error log to named file --malloc-lib Alternative malloc library to use for mysqld --mysqld Name of server program to start (in ledir directory) --mysqld-version Suffix for server program name --nice Use nice program to set server scheduling priority --no-defaults Read no option files --open-files-limit Number of files that mysqld should be able to open --pid-file Path name of server process ID file --plugin-dir Directory where plugins are installed --port Port number on which to listen for TCP/IP connections --skip-kill-mysqld Do not try to kill stray mysqld processes --skip-syslog Do not write error messages to syslog; use error log file --socket Socket file on which to listen for Unix socket connections --syslog Write error messages to syslog --syslog-tag Tag suffix for messages written to syslog --timezone Set TZ time zone environment variable to named value --user Run mysqld as user having name user_name or numeric user ID user_id
参考文档: