MySQL Forums :: General :: startup mysql as service on redhat enterprise linux 6.4


Advanced Search

startup mysql as service on redhat enterprise linux 6.4
Posted by: harry sheng ()
Date: September 24, 2014 09:43AM

Hi,

I have a brand new REL6.4 server, I want to setup MySQL 5.6.16 server as a service so that MySQL will startup automatically as the OS reboot.

Here is what I have tried (and more),

# rpm -ivh --force MySQL-server-5.6.16-1.el6.x86_64.rpm
# rpm -ivh MySQL-client-5.6.16-1.el6.x86_64.rpm
# service mysql start
(OK, mysqld started)
# service mysql stop

# mkdir /opt/mysql/data
# mysql_install_db --datadir=/opt/mysql/data
(OK, new instance created, looks good)

# chown -R mysql:mysql /opt/mysql
### modify /etc/my.cnf to use the instance in /opt/mysql/data (user=mysql is in /etc/my.cnf)

# mysqld_safe --defaults-file=/etc/my.cnf
(OK, mysqld started, I can access the database from mysql client)
### shutdown mysql

### modify /etc/init.d/mysql to point "datadir" to /opt/mysql/data (no other change)
# service mysql start
(*** Failed here ***)
2014-09-24 07:54:13 4397 [ERROR] InnoDB: ./ibdata1 can't be opened in read-write mode

# ls -l /opt/mysql
total 4
drwxr-xr-x. 5 mysql mysql 4096 Sep 24 11:15 data

# ls -l /opt/mysql/data
total 110620
-rw-rw----. 1 mysql mysql 56 Sep 24 10:59 auto.cnf
-rw-rw----. 1 mysql mysql 12582912 Sep 24 11:15 ibdata1
-rw-rw----. 1 mysql mysql 50331648 Sep 24 11:15 ib_logfile0
-rw-rw----. 1 mysql mysql 50331648 Sep 24 10:49 ib_logfile1
drwx------. 2 mysql mysql 4096 Sep 24 10:49 mysql
-rw-rw----. 1 mysql mysql 5 Sep 24 11:15 mysqld.pid
-rw-r-----. 1 mysql root 7424 Sep 24 11:15 mysql-server.log
srwxrwxrwx. 1 mysql mysql 0 Sep 24 11:15 mysql.sock
drwx------. 2 mysql mysql 4096 Sep 24 10:49 performance_schema
drwx------. 2 mysql mysql 4096 Sep 24 10:49 test


### reset "datadir" in /etc/init.d/mysql
# service mysql start
(No problem, mysqld started from /var/lib/mysql)
[root@localhost ~]# ls -l /var/lib/mysql/
total 110616
-rw-rw----. 1 mysql mysql 56 Sep 24 10:17 auto.cnf
-rw-rw----. 1 mysql mysql 12582912 Sep 24 10:36 ibdata1
-rw-rw----. 1 mysql mysql 50331648 Sep 24 10:36 ib_logfile0
-rw-rw----. 1 mysql mysql 50331648 Sep 24 10:15 ib_logfile1
drwx--x--x. 2 mysql mysql 4096 Sep 24 10:15 mysql
drwx------. 2 mysql mysql 4096 Sep 24 10:15 performance_schema
-rw-r--r--. 1 root root 111 Sep 24 10:15 RPM_UPGRADE_HISTORY
-rw-r--r--. 1 mysql mysql 111 Sep 24 10:15 RPM_UPGRADE_MARKER-LAST
drwxr-xr-x. 2 mysql mysql 4096 Sep 24 10:15 test


Any special settings to get mysqld started as a service from non-default location?

thanks

Options: ReplyQuote


Subject Written By Posted
startup mysql as service on redhat enterprise linux 6.4 harry sheng 09/24/2014 09:43AM
Re: startup mysql as service on redhat enterprise linux 6.4 harry sheng 09/24/2014 01:08PM
Re: startup mysql as service on redhat enterprise linux 6.4 harry sheng 10/06/2014 12:41PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.