Linux下將MySQL服務添加到伺服器的系統服務中

來源:互聯網
上載者:User

標籤:http   io   ar   sp   for   strong   資料   on   div   

 Linux下將MySQL服務添加到伺服器的系統服務中

Linux環境下將MySQL服務添加到伺服器的系統服務中

1、瞭解MySQL程式路徑
 
MySQL資料目錄: /home/mysql/data
MySQL程式目錄:/usr/local/mysql5
 
2、修改MySQL服務啟動程式
 
[[email protected] www.linuxidc.com ~]# vim /usr/local/mysql5/share/mysql/mysql.server
46 basedir=/usr/local/mysql5
47 datadir=/home/mysql/data
 
3、拷貝啟動程式
 
[[email protected] www.linuxidc.com ~]# cp -ar /usr/local/mysql5/share/mysql/mysql.server /etc/init.d/mysqld
 
4、啟動MySQL服務
 
[[email protected] www.linuxidc.com ~]# netstat -nltp |grep mysql 
[[email protected] www.linuxidc.com ~]# service mysqld start
Starting MySQL.[OK]
[[email protected] www.linuxidc.com ~]# netstat -nltp |grep mysql 
tcp00 0.0.0.0:33060.0.0.0:*LISTEN5877/mysqld
 
5、進入MySQL資料庫
 
[[email protected] www.linuxidc.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, 2013, 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、MySQL服務的關閉與重新啟動
 
[[email protected] www.linuxidc.com ~]# service mysqld stop 
Shutting down MySQL.[OK]
[[email protected] www.linuxidc.com ~]# netstat -nltp |grep mysql 
[[email protected] www.linuxidc.com ~]# service mysqld restart 
MySQL manager or server PID file could not be found![FAILED]
Starting MySQL..[OK]
[[email protected] www.linuxidc.com ~]# service mysqld restart 
Shutting down MySQL.....[OK]
Starting MySQL.[OK]
[[email protected] www.linuxidc.com ~]#

推薦閱讀:

Xshell遠端管理MySQL伺服器如何?選擇自動複製以及右鍵自動粘貼的設定!  http://www.linuxidc.com/Linux/2013-06/85933.htm

Linux下將MySQL服務添加到伺服器的系統服務中

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.