mysql-5.1.68的啟動和停止以及相關協議

tolilong發表於2013-02-24
1,mysqld[@more@]
  • Mysqld is the mysql server
  • Mysql read options from the [mysqld] and [server] groups
  • 直接呼叫的話,error message會定位到終端,不會到日誌

[root@oracle bin]# ./mysqladmin shutdown
[root@oracle bin]# ps -ef | grep mysql
root 14146 13810 0 07:02 pts/3 00:00:00 grep mysql
[root@oracle bin]# cd ../libexec/
[root@oracle libexec]# pwd
/u02/mysql5168/libexec
[root@oracle libexec]# ./mysqld --defaults-file=/u02/my.cnf --user=mysql
130224 7:03:40 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
130224 7:03:40 InnoDB: Initializing buffer pool, size = 8.0M
130224 7:03:40 InnoDB: Completed initialization of buffer pool
130224 7:03:40 InnoDB: Started; log sequence number 0 44233
130224 7:03:40 [Note] Event Scheduler: Loaded 0 events
130224 7:03:40 [Note] ./mysqld: ready for connections.
Version: '5.1.68bruce' socket: '/tmp/mysql.sock' port: 3306 Source distribution



2,mysqld_safe
 Mysqld_safe read all options from [mysqld][server][mysqld_safe]
 Mysqld_safe is shell script 可以呼叫mysqld,mysqld_safe set up error log,if mysqld_safe terminated abnormally,mysqld_safe restart it

[root@oracle bin]# ./mysqladmin shutdown
[root@oracle bin]# cd bin
-bash: cd: bin: No such file or directory
[root@oracle bin]# pwd
/u02/mysql5168/bin
[root@oracle bin]# ./mysqld_safe --defaults-file=/u02/my.cnf --user=mysql
130224 07:17:21 mysqld_safe Logging to '/u02/mysql5168/data/oracle.err'.
130224 07:17:21 mysqld_safe Starting mysqld daemon with databases from /u02/mysql5168/data

從後臺程式看,mysqld_safe是直接呼叫mysqld的,mysqld_safe就是mysqld的父程式.
[root@oracle ~]# ps -ef | grep mysql
root 14281 14161 0 07:17 pts/1 00:00:00 /bin/sh ./mysqld_safe --defaults-file=/u02/my.cnf --user=mysql
mysql 14393 14281 0 07:17 pts/1 00:00:00 /u02/mysql5168/libexec/mysqld --defaults-file=/u02/my.cnf --basedir=/u02/mysql5168 --datadir=/u02/mysql5168/data --user=mysql --log-error=/u02/mysql5168/data/oracle.err --pid-file=/u02/mysql5168/data/oracle.pid --socket=/tmp/mysql.sock --port=3306
root 14439 14406 0 07:17 pts/2 00:00:00 grep mysql
[root@oracle ~]# cd /u02/mysql5168/bin/
[root@oracle bin]# ./mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.1.68bruce Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql>

設定為後臺啟動:
[root@oracle bin]# ./mysqladmin shutdown
[root@oracle bin]# ./mysqld_safe --defaults-file=/u02/my.cnf --user=mysql &
[1] 14617
[root@oracle bin]# 130224 07:22:34 mysqld_safe Logging to '/u02/mysql5168/data/oracle.err'.
130224 07:22:34 mysqld_safe Starting mysqld daemon with databases from /u02/mysql5168/data



3,mysql.server以服務啟動
$mysql_base/share/mysql/mysql.server & support-files/mysql.server
A shell script直接呼叫mysqld_safe

[root@oracle bin]# ./mysqladmin shutdown
130224 07:26:09 mysqld_safe mysqld from pid file /u02/mysql5168/data/oracle.pid ended
[1]+ Done ./mysqld_safe --defaults-file=/u02/my.cnf --user=mysql
[root@oracle bin]# cd ../share/mysql/
[root@oracle mysql]# pwd
/u02/mysql5168/share/mysql
[root@oracle mysql]# ./mysql.server --help
Usage: ./mysql.server {start|stop|restart|reload|force-reload|status} [ MySQL server options ]

[root@oracle mysql]# cp mysql.server /etc/rc.d/init.d/mysqld51
[root@oracle mysql]# chkconfig --add mysqld51
[root@oracle mysql]# chkconfig --list mysqld51
mysqld51 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@oracle mysql]# service mysqld51 start






Mysql的相關協議
Protocol type of connections supported OS
TCP/IP local,remote all
Unix socket file local only unix only
Named pipe local only windows only
Shared memory local only windows only

 TCP/IP connections are supported by any mysql server unless the server is started with the –skip-networking option
 Unix socket file connections are supportd by all unix servers
 Named-pipe connectsions are supported only on windows and only if you use one of the servers that has –nt in its name(mysql-nt,mysql-max-nt),however,named pipes are disabled by default,to enable named-pipe connectsion,you must start the –nt server with the –enable-name-pipe option
 Shared-memory connections are supported by all windows servers,but are disable by default. To enable shared-memory connections,you must start the server with the
–shared-mmeory option


常用客戶端工具:mysql ,mysqladmin,mysqlimport,mysqldump

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24237320/viewspace-1060239/,如需轉載,請註明出處,否則將追究法律責任。

相關文章