Add the MySQL service to the System Service of the server in Linux

Source: Internet
Author: User

Add the MySQL service to the System Service of the server in Linux

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 @ www.bkjia.com ~] # Vim/usr/local/mysql5/share/mysql. server
46 basedir =/usr/local/mysql5
47 datadir =/home/mysql/data
 
3. Copy the Startup Program
 
[Root @ www.bkjia.com ~] # Cp-ar/usr/local/mysql5/share/mysql. server/etc/init. d/mysqld
 
4. Start the MySQL Service
 
[Root @ www.bkjia.com ~] # Netstat-nltp | grep mysql
[Root @ www.bkjia.com ~] # Service mysqld start
Starting MySQL. [OK]
[Root @ www.bkjia.com ~] # Netstat-nltp | grep mysql
Tcp00 0.0.0.0: 33060.0.0.0: * LISTEN5877/mysqld
 
5. Enter the MySQL database
 
[Root @ www.bkjia.com ~] #/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) 2000,201 3, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.
Mysql>
 
6. Close and restart the MySQL Service
 
[Root @ www.bkjia.com ~] # Service mysqld stop
Shutting down MySQL. [OK]
[Root @ www.bkjia.com ~] # Netstat-nltp | grep mysql
[Root @ www.bkjia.com ~] # Service mysqld restart
MySQL manager or server PID file cocould not be found! [FAILED]
Starting MySQL... [OK]
[Root @ www.bkjia.com ~] # Service mysqld restart
Shutting down MySQL... [OK]
Starting MySQL. [OK]
[Root @ www.bkjia.com ~] #

Recommended reading:

Xshell Remote Management MySQL Server How to Select Automatic copy and right-click automatic paste settings!

Related Article

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.