0

I need help . mysql on port 3306 and mysql2 on port 3307.

I copied my.cnf to my2.cnf

I added the following in my2.cnf:

datadir=/var/lib/mysql2 port=3307

cp /etc/init.d/mysql /etc/init.d/mysql2

Added to line 138 in vi /etc/init.d/mysql2:

--port=*) port=echo "$arg" | sed -e 's/^[^=]*=//' ;;

edited line 215:

conf=/etc/my2.cnf

line 257 add -c flag:

parse_server_arguments $print_defaults $extra_args mysqld server mysql_server mysql.server -c/etc/my2.cnf

Add port argument to mysql_safe command on line 284:

$bindir/mysqld_safe --defaults-file=/etc/my2.cnf --datadir="$datadir" --pid-file="$mysqld_pid_file_path" --port="$port" --socket="$datadir"/mysql2.sock $other_args >/dev/null 2>&1 &

added the server to the start up list

chkconfig --add mysql2 chkconfig mysql2 --level 2345 on

currently when i reboot the system and check the status. I get:

[root@localhost ~]# service mysql status

ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists

[root@localhost ~]# service mysql2 status

ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists

[root@localhost ~]# service mysql2 start

Starting MySQL... SUCCESS!

[root@localhost ~]# service mysql start

Starting MySQL...... SUCCESS!

what am i doing wrong or do i need to do to get both start on boot

atuomatically? please help.

4
  • Try change $mysqld_pid_file_path for each server Nov 4, 2015 at 21:48
  • CentOS 7 has switched to using systemd, so it's likely that your init script isn't getting called at boot time but your first instance is getting started by systemd.
    – GregL
    Nov 5, 2015 at 0:12
  • Also, please fix the formatting of your question, it's very hard to read.
    – GregL
    Nov 5, 2015 at 0:13
  • @GregL I thought about that but thought there was a way out. Thank you . and I will do my best to format my question well next time.
    – Lolu911
    Nov 5, 2015 at 15:22

1 Answer 1

1

Open the file /etc/init.d/mysql /etc/init.d/mysql2 and find the following section

# Lock directory for RedHat / SuSE.
lockdir='/var/lock/subsys'
lock_file_path="$lockdir/mysql"

Change lock_file_path="$lockdir/mysql" to lock_file_path="$lockdir/mysql2"

Should fix the issue :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .