mysql dba系统学习(3)mysql的启动停止
mysql的启动有很多方法,我们将来一一讨论 一,mysqld mysqld是mysql的服务 mysqld这种方式启动的时候会读取my.cnf文件中的[mysqld]和[server]组group (每一个组都有[]来分割) 一般的,我们通过这种方式手动的调用mysqld,如果不是出去调试的目的,我们一般都不这样做。 因为这种方式会使错误日志直接从终端输出,而不是记录在错误日志文件中,这样,如果mysql崩溃的话 我们也不知道原因。 连接方法 start [root@test4 ~]# /usr/local/mysql/libexec/mysqld --defaults-file=/etc/my.cnf --user=mysql 130617 7:22:58 [Note] Event Scheduler: Loaded 0 events 130617 7:22:58 [Note] /usr/local/mysql/libexec/mysqld: ready for connections. Version: '5.1.70-log' socket: '/tmp/mysql.sock' port: 3306 Source distribution [root@test4 ~]# ps aux|grep mysql mysql 19327 0.0 1.3 125304 6648 pts/0 Sl+ 07:22 0:00 /usr/local/mysql/libexec/mysqld --defaults-file=/etc/my.cnf --user=mysql connnect mysqld --defaults-file=/etc/my.cnf mysqld -S /tmp/mysql.sock 二,mysqld_safe mysqld_safe这种方式启动的时候会读取my.cnf文件中的[mysqld],[server]和[mysqld_safe]组group,但是为了兼容,也会读取[safe_mysqld]这个组 mysqld_safe是一个调用mysqld的shell脚本,它还设置了错误日志,它可以启动mysqld和monitor mysqld进程,这样,如果mysqld的进程异常终止,mysqld_safe会重启mysqld [root@test4 ~]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql & [1] 20571 [root@test4 ~]# 130617 07:57:29 mysqld_safe Logging to '/usr/local/mysql/var/test4.wolf.org.err'. 130617 07:57:29 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var [root@test4 ~]# [root@test4 ~]# ps aux|grep mysql root 20571 1.0 0.2 106012 1344 pts/0 S 07:57 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql mysql 20680 1.0 1.3 125308 6652 pts/0 Sl 07:57 0:00 /usr/local/mysql/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --user=mysql --log-error=/usr/local/mysql/var/test4.wolf.org.err --pid-file=/usr/local/mysql/var/test4.wolf.org.pid --socket=/tmp/mysql.sock --port=3306 报错: mysqld_safe Logging to '/usr/local/mysql/data/Linux.err'. mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data mysqld_safe mysqld from pid file /usr/local/mysql/data/Linux.pid ended 解决方法:初始化mysql [root@test4 ~]# /usr/local/mysql/bin/mysql_install_db --user=mysql 二,mysql.server mysql.server是一个调用mysqld_safe的shell脚本 它的执行文件在$MYSQL_BASE/share/mysql/mysql.server 和 support-files/mysql.server mysql.server的启动会读取[mysql.server]和[mysqld],为了兼容,也会读取[mysql_server]组 [root@test4 ~]# cp mysql-5.1.70/support-files/mysql.server /etc/init.d/mysql [root@test4 ~]# chmod u+x /etc/init.d/mysqld [root@test4 ~]# service mysqld start Starting MySQL SUCCESS! [root@test4 ~]# ps aux|grep mysql root 20571 0.0 0.2 106012 1344 pts/0 S 07:57 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql mysql 20680 0.0 1.3 125308 6652 pts/0 Sl 07:57 0:00 /usr/local/mysql/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --user=mysql --log-error=/usr/local/mysql/var/test4.wolf.org.err --pid-file=/usr/local/mysql/var/test4.wolf.org.pid --socket=/tmp/mysql.sock --port=3306 出处:http://wolfword.blog.51cto.com/4892126/1241303 查看本栏目更多精彩内容:http://www.bianceng.cn/database/MySQL/ (编辑:淮北站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |