mysqld_safe启动mysql数据库的参数

一般启动mysql可以使用/etc/init.d/mysqld启动进行启动

#/etc/init.d/mysqld start

 

也可以使用/usr/local/mysql/bin/mysqld_safe进行启动

chown -R mysql:mysql /data

1#/usr/local/mysql/scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/data #初始化

ll /data

total 1056

drwx—— 2 mysql root 4096 May 1 21:31 mysql

-rw-rw—- 1 mysql mysql 27311 May 1 21:31 mysql-bin.000001

-rw-rw—- 1 mysql mysql 1031892 May 1 21:31 mysql-bin.000002

-rw-rw—- 1 mysql mysql 38 May 1 21:31 mysql-bin.index

drwx—— 2 mysql mysql 4096 May 1 21:31 performance_schema

drwx—— 2 mysql root 4096 May 1 21:31 test

 

2)#/usr/local/mysql/bin/mysqld_safe –user=mysql –basedir=/usr/local/mysql –datadir=/data & 启动mysql服务

 

#netstat -anpt | grep mysqld

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1180/mysqld

ps -ef | grep mysqld

root 906 19026 0 21:32 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe –user=mysql –basedir=/usr/local/mysql –datadir=/data

mysql 1180 906 0 21:32 pts/0 00:00:00 /usr/local/mysql/bin/mysqld –basedir=/usr/local/mysql –datadir=/data –plugin-dir=/usr/local/mysql/lib/plugin –user=mysql –log-error=/data/vm1.test.com.err –pid-file=/data/vm1.test.com.pid –socket=/tmp/mysql.sock –port=3306

 

或者:

3)mysqld_safe –defaults-file=/etc/my2.cnf –user=mysql2 #这样也可以启动mysql

我们可以利用该方法启动2个mysql实例:

chown -R mysql2:mysql2 /usr/local/mysql/data/

/usr/local/mysql/bin/mysqld_safe –defaults-file=/etc/my.cnf –user=mysql2 &

netstat -anpt | grep mysql

tcp 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN 13551/mysqld

ps -ef | grep mysql

root 13311 19026 0 21:42 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe –defaults-file=/etc/my.cnf –user=mysql2

mysql2 13551 13311 1 21:42 pts/0 00:00:00 /usr/local/mysql/bin/mysqld –defaults-file=/etc/my.cnf –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data –plugin-dir=/usr/local/mysql/lib/plugin –user=mysql2 –log-error=/usr/local/mysql/data/vm1.test.com.err –pid-file=/usr/local/mysql/data/vm1.test.com.pid –socket=/tmp/mysql.sock –port=3307

 

在Unix和NetWare中推荐使用mysqld_safe来启动mysqld服务器。mysqld_safe增加了一些安全特性,例如当出现错误时重启服务器并向错误日志文件写入运行时间信息。

 

    原文作者:mysql
    原文地址: https://www.cnblogs.com/gdlinux/p/6793058.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞