centos7上如何配置MySQL5.7的開機自啟動-創(chuàng)新互聯(lián)

這篇文章主要為大家展示了“centos7上如何配置MySQL5.7的開機自啟動”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“centos7上如何配置MySQL5.7的開機自啟動”這篇文章吧。

創(chuàng)新互聯(lián)公司從2013年成立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目成都網(wǎng)站設(shè)計、網(wǎng)站建設(shè)網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元西藏做網(wǎng)站,已為上家服務(wù),為西藏各地企業(yè)和個人服務(wù),聯(lián)系電話:13518219792

centos7開始使得以往老版本系統(tǒng)服務(wù)的/etc/init.d的啟動腳本的方式就此改變,在centos7中所有對服務(wù)的管理都集中到了systemctl當(dāng)中。
systemctl是一個系統(tǒng)管理守護進程、工具和庫的集合,用于取代以往的System V、service和chkconfig命令。

創(chuàng)建用于啟動MySQL的配置文件
[root@localhost ~]# touch /usr/lib/systemd/system/mysqld.service
[root@localhost ~]# cd /usr/lib/systemd/system

編輯mysqld.service文件,加入如下內(nèi)容:
[root@localhost system]# vi mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target

[Service]
User=mysql
Group=mysql
ExecStart=/opt/mysql-5.7.18/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
保存退出

備注:ExecStart=/opt/mysql-5.7.18/bin/mysqld (此處請對應(yīng)修改為MySQL程序所在的路徑)
查找mysqld路徑,例如:
[root@localhost system]# which mysqld
/opt/mysql-5.7.18/bin/mysqld


通過systemctl方式啟動mysql5.7:
[root@localhost system]# systemctl start mysqld


檢查MySQL運行狀態(tài):
[root@localhost system]# mysql -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.18-log MySQL Community Server (GPL)


Copyright (c) 2000, 2017, 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> 
mysql> 
mysql> \s
--------------
mysql  Ver 14.14 Distrib 5.7.18, for linux-glibc2.5 (x86_64) using  EditLine wrapper


Connection id: 6
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.18-log MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db     characterset: latin1
Client characterset: utf8
Conn.  characterset: utf8
UNIX socket: /tmp/mysql.sock
Uptime: 45 sec


Threads: 3  Questions: 6  Slow queries: 0  Opens: 108  Flush tables: 1  Open tables: 101  Queries per second avg: 0.133
--------------

mysql> 

關(guān)閉防火墻:
[root@localhost system]# systemctl stop firewalld.service
[root@localhost system]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

設(shè)置mysql的開機啟動:
[root@localhost system]# systemctl enable mysqld
Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service.
[root@localhost system]# systemctl list-unit-files | grep mysqld
mysqld.service                                enabled 


取消mysql的開機自啟動:
[root@localhost system]# systemctl disable mysqld
Removed symlink /etc/systemd/system/multi-user.target.wants/mysqld.service.
[root@localhost system]# systemctl list-unit-files | grep mysqld
mysqld.service                                disabled

以上是“centos7上如何配置MySQL5.7的開機自啟動”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道!

分享名稱:centos7上如何配置MySQL5.7的開機自啟動-創(chuàng)新互聯(lián)
瀏覽路徑:http://muchs.cn/article18/hepdp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設(shè)、自適應(yīng)網(wǎng)站、網(wǎng)站內(nèi)鏈、服務(wù)器托管、靜態(tài)網(wǎng)站軟件開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)