How to add a MySQL service to the server's system services

Source: Internet
Author: User

1, understand the MySQL program path

MySQL Data directory:/home/mysql/data

MySQL Program directory:/USR/LOCAL/MYSQL5

2, modify the MySQL service startup program

[root@lyq314 ~]# Vim/usr/local/mysql5/share/mysql/mysql.server

Basedir=/usr/local/mysql5

Datadir=/home/mysql/data

3. Copy Start Program

[root@lyq314 ~]# Cp-ar/usr/local/mysql5/share/mysql/mysql.server/etc/init.d/mysqld

4. Start MySQL Service

[root@lyq314 ~]# netstat-nltp |grep MySQL

[root@lyq314 ~]# Service mysqld start

Starting MySQL. [OK]

[root@lyq314 ~]# netstat-nltp |grep MySQL

Tcp00 0.0.0.0:33060.0.0.0:*listen5877/mysqld

5, into the MySQL database

[root@lyq314 ~]#/usr/local/mysql5/bin/mysql-uroot-p-s/tmp/mysql.sock

Enter Password:

Welcome to the MySQL monitor.commands end with; or \g.

Your MySQL Connection ID is 1

Server Version:5.1.68-log Source Distribution

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

This column more highlights: http://www.bianceng.cn/database/MySQL/

Oracle is a registered trademark the Oracle Corporation and/or its

Affiliates. Names may trademarks of their respective

Owners.

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

Mysql>

6, the MySQL service shutdown and restart

[root@lyq314 ~]# service mysqld Stop

Shutting down MySQL. [OK]

[root@lyq314 ~]# netstat-nltp |grep MySQL

[root@lyq314 ~]# Service mysqld Restart

MySQL Manager or server PID file could not is found! [FAILED]

Starting MySQL. [OK]

[root@lyq314 ~]# Service mysqld Restart

Shutting down MySQL ..... [OK]

Starting MySQL. [OK]

[Root@lyq314 ~]#

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.