請問mysqld問題 [論壇 - Ubuntu 與工具程式及軟體推薦]


正在瀏覽:   1 名遊客


 到底部   前一個主題   下一個主題  [無發表權] 請登錄或者註冊



請問mysqld問題
會員一級
註冊日期:
5/26 13:35:58
所屬群組:
已註冊使用者
等級: 1
HP : 0 / 11
MP : 2 / 8
EXP: 47
離線
我有個程式需要執行這個指令
/etc/init.d/mysqld start
結果bash: /etc/init.d/mysqld: 沒有此一檔案或目錄
我去看了檔案只有mysql

執行 sudo start mysql
start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: 連線被拒絕

/etc/init.d/mysql start
[ ok ] Starting mysql (via systemctl): mysql.service.
service mysqld start
Failed to start mysqld.service: Unit mysqld.service not found.


mysql server有安裝 , 求解 謝謝

7/24 11:51:19
應用擴展 工具箱
回覆: 請問mysqld問題
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 32
HP : 155 / 776
MP : 464 / 12107
EXP: 7
離線
samsin 寫到:
我有個程式需要執行這個指令
/etc/init.d/mysqld start
結果bash: /etc/init.d/mysqld: 沒有此一檔案或目錄
我去看了檔案只有mysql

執行 sudo start mysql
start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: 連線被拒絕

/etc/init.d/mysql start
[ ok ] Starting mysql (via systemctl): mysql.service.
service mysqld start
Failed to start mysqld.service: Unit mysqld.service not found.


mysql server有安裝 , 求解 謝謝


================================================================================

不確定在您的環境,發生這個狀況的關鍵因素是啥,

所以提供我環境的操作步驟給您參考,供您對照。

以下測試是在「Xubuntu 16.04 amd64 英文界面」

已經有安裝「mysql-server」了,

================================================================================


所以可以執行下面指令


$ sudo /etc/init.d/mysql



顯示


Usage: /etc/init.d/mysql start|stop|restart|reload|force-reload|status



關於「/etc/init.d/mysql」只是「Shell Script」,您可以直接觀看該檔的內容。


一些相關的討論案例,可以參考另一篇「[索引] 開機流程」,
在下方有「## init」哪裡有紀錄一些「參考連結」和「討論案例」。

--------------------------------------------------------------------------------

## init script

### status

執行


$ sudo /etc/init.d/mysql status



顯示


● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2017-07-24 14:34:59 CST; 1min 21s ago
Process: 4990 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 4981 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 4989 (mysqld)
CGroup: /system.slice/mysql.service
└─4989 /usr/sbin/mysqld

Jul 24 14:34:58 house systemd[1]: Starting MySQL Community Server...
Jul 24 14:34:59 house systemd[1]: Started MySQL Community Server.



執行


$ ps aux | grep mysql



顯示


mysql 4989 0.7 2.4 1246952 147828 ? Ssl 14:34 0:00 /usr/sbin/mysqld
user 5067 0.0 0.0 12884 1092 pts/9 S+ 14:35 0:00 grep --color=auto mysql



--------------------------------------------------------------------------------

### restart

執行


$ sudo /etc/init.d/mysql restart



顯示


[ ok ] Restarting mysql (via systemctl): mysql.service.



--------------------------------------------------------------------------------

### stop

執行


$ sudo /etc/init.d/mysql stop



顯示


[ ok ] Stopping mysql (via systemctl): mysql.service.



--------------------------------------------------------------------------------

### start

執行


$ sudo /etc/init.d/mysql start



顯示


[ ok ] Starting mysql (via systemctl): mysql.service.



================================================================================

## systemd

接下來,直接透過「systemctl」這個指令來操作,也就是「systemd」的機制。

這個會跟「/lib/systemd/system/mysql.service」這個檔案相關。

### status

執行


$ sudo systemctl status mysql



顯示


● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2017-07-24 14:40:37 CST; 2s ago
Process: 5308 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 5299 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 5307 (mysqld)
CGroup: /system.slice/mysql.service
└─5307 /usr/sbin/mysqld

Jul 24 14:40:36 house systemd[1]: Starting MySQL Community Server...
Jul 24 14:40:37 house systemd[1]: Started MySQL Community Server.


--------------------------------------------------------------------------------

### restart

執行


$ sudo systemctl restart mysql



沒有任何顯示,會直接跳下一個提示字元

--------------------------------------------------------------------------------

### stop

執行


$ sudo systemctl stop mysql



沒有任何顯示,會直接跳下一個提示字元

--------------------------------------------------------------------------------

### start

執行


$ sudo systemctl start mysql



沒有任何顯示,會直接跳下一個提示字元


================================================================================

## service

接下來透過「service」這個指令來操作。

### status


$ sudo service mysql status



顯示


● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2017-07-24 14:45:14 CST; 1min 13s ago
Process: 5510 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 5502 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 5509 (mysqld)
CGroup: /system.slice/mysql.service
└─5509 /usr/sbin/mysqld

Jul 24 14:45:13 house systemd[1]: Starting MySQL Community Server...
Jul 24 14:45:14 house systemd[1]: Started MySQL Community Server.



--------------------------------------------------------------------------------

### restart


$ sudo service mysql restart



沒有任何顯示,會直接跳下一個提示字元

--------------------------------------------------------------------------------

### stop


$ sudo service mysql stop



沒有任何顯示,會直接跳下一個提示字元

--------------------------------------------------------------------------------

### start


$ sudo service mysql start



沒有任何顯示,會直接跳下一個提示字元

================================================================================

接下來討論如何確認「mysql-server」是否已經安裝,待續...

7/24 15:43:24
應用擴展 工具箱
回覆: 請問mysqld問題
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 32
HP : 155 / 776
MP : 464 / 12107
EXP: 7
離線
接下來討論如何確認「mysql-server」是否已經安裝

一些套件操作的討論案例,紀錄在「[索引] 套件操作實務」。

================================================================================

執行下面指令,安裝「mysql-server」這個套件


$ sudo apt-get install mysql-server




安裝好後,可以執行下面指令確認


$ dpkg -l mysql-server



顯示


Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=============================-===================-===================-=======
ii mysql-server 5.7.19-0ubuntu0.16. all MySQL database server (metapackage depending on the latest versi



執行


$ dpkg -L mysql-server



顯示


/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/mysql-server
/usr/share/doc/mysql-server/copyright
/usr/share/doc/mysql-server/NEWS.Debian.gz
/usr/share/doc/mysql-server/changelog.Debian.gz



發現只有上面的檔案,根據經驗,猜測「mysql-server」這個套件,只是「MetaPackages」。

所以執行


$ apt-cache show mysql-server



顯示


Package: mysql-server
Priority: optional
Section: database
Installed-Size: 172
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian MySQL Maintainers <pkg-mysql-maint@lists.alioth.debian.org>
Architecture: all
Source: mysql-5.7
Version: 5.7.19-0ubuntu0.16.04.1
Depends: mysql-server-5.7
Filename: pool/main/m/mysql-5.7/mysql-server_5.7.19-0ubuntu0.16.04.1_all.deb
Size: 10834
MD5sum: d999612e985409131dcabc7cf5ac4c76
SHA1: cca4ae9756f1bd987797e6880fabce4e37a03bab
SHA256: 0bf7ae58e2180b3f39c3df2030ddfd26671b80f2eb4ad23cf8fe9d41df8ef38c
Description-en: MySQL database server (metapackage depending on the latest version)
This is an empty package that depends on the current "best" version of
mysql-server (currently mysql-server-5.7), as determined by the MySQL
maintainers. Install this package if in doubt about which MySQL
version you need. That will install the version recommended by the
package maintainers.
.
MySQL is a fast, stable and true multi-user, multi-threaded SQL database
server. SQL (Structured Query Language) is the most popular database query
language in the world. The main goals of MySQL are speed, robustness and
ease of use.
Description-md5: b8b44aa3bf1e86bb2834ded6d9d869b5
Homepage: http://dev.mysql.com/
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 5y
Task: lamp-server, mythbuntu-frontend, mythbuntu-desktop, mythbuntu-backend-slave, mythbuntu-backend-master, mythbuntu-backend-master



或是也可以執行下面指令


$ apt-cache show mysql-server | grep '^Depends:'



顯示


Depends: mysql-server-5.7



從上面可以了解到,安裝「mysql-server」這個套件,
就會一併安裝「mysql-server-5.7」這個套件

所以我們可以執行下面指令來確認「mysql-server-5.7」這個套件是否已經安裝在系統上,


$ dpkg -l mysql-server-5.7



顯示


Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=============================-===================-===================-========
ii mysql-server-5.7 5.7.19-0ubuntu0.16. amd64 MySQL database server binaries and system database setup



執行


$ dpkg -L mysql-server-5.7



或是執行


$ dpkg -L mysql-server-5.7 | sort



顯示


/.
/etc
/etc/apparmor.d
/etc/apparmor.d/usr.sbin.mysqld
/etc/init
/etc/init.d
/etc/init.d/mysql
/etc/init/mysql.conf
/etc/logcheck
/etc/logcheck/ignore.d.paranoid
/etc/logcheck/ignore.d.paranoid/mysql-server-5_7
/etc/logcheck/ignore.d.server
/etc/logcheck/ignore.d.server/mysql-server-5_7
/etc/logcheck/ignore.d.workstation
/etc/logcheck/ignore.d.workstation/mysql-server-5_7
/etc/logrotate.d
/etc/logrotate.d/mysql-server
/etc/mysql
/etc/mysql/debian-start
/etc/mysql/mysql.cnf
/etc/mysql/mysql.conf.d
/etc/mysql/mysql.conf.d/mysqld.cnf
/etc/mysql/mysql.conf.d/mysqld_safe_syslog.cnf
/lib
/lib/systemd
/lib/systemd/system
/lib/systemd/system/mysql.service
/usr
/usr/bin
/usr/bin/myisamchk
/usr/bin/myisamlog
/usr/bin/myisampack
/usr/bin/mysqlbinlog
/usr/bin/mysqld_multi
/usr/bin/mysqld_safe
/usr/bin/mysql_plugin
/usr/bin/mysql_secure_installation
/usr/bin/mysql_ssl_rsa_setup
/usr/bin/mysql_tzinfo_to_sql
/usr/bin/perror
/usr/bin/replace
/usr/bin/resolveip
/usr/lib
/usr/lib/mysql
/usr/lib/mysql/lz4_decompress
/usr/lib/mysql/plugin
/usr/lib/mysql/plugin/adt_null.so
/usr/lib/mysql/plugin/auth_socket.so
/usr/lib/mysql/plugin/connection_control.so
/usr/lib/mysql/plugin/innodb_engine.so
/usr/lib/mysql/plugin/keyring_file.so
/usr/lib/mysql/plugin/libmemcached.so
/usr/lib/mysql/plugin/locking_service.so
/usr/lib/mysql/plugin/mypluglib.so
/usr/lib/mysql/plugin/mysql_no_login.so
/usr/lib/mysql/plugin/rewriter.so
/usr/lib/mysql/plugin/semisync_master.so
/usr/lib/mysql/plugin/semisync_slave.so
/usr/lib/mysql/plugin/validate_password.so
/usr/lib/mysql/plugin/version_token.so
/usr/lib/mysql/resolve_stack_dump
/usr/lib/mysql/zlib_decompress
/usr/share
/usr/share/apport
/usr/share/apport/package-hooks
/usr/share/apport/package-hooks/source_mysql-5.7.py
/usr/share/doc
/usr/share/doc/mysql-server-5.7
/usr/share/doc/mysql-server-5.7/changelog.Debian.gz
/usr/share/doc/mysql-server-5.7/copyright
/usr/share/doc/mysql-server-5.7/examples
/usr/share/doc/mysql-server-5.7/examples/daemon_example.ini
/usr/share/doc/mysql-server-5.7/examples/magic
/usr/share/doc/mysql-server-5.7/mysqld.sym.gz
/usr/share/doc/mysql-server-5.7/NEWS.Debian.gz
/usr/share/doc/mysql-server-5.7/README.Debian.gz
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/mysql-server-5.7
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/lz4_decompress.1.gz
/usr/share/man/man1/myisamchk.1.gz
/usr/share/man/man1/myisamlog.1.gz
/usr/share/man/man1/myisampack.1.gz
/usr/share/man/man1/mysqlbinlog.1.gz
/usr/share/man/man1/mysqld_multi.1.gz
/usr/share/man/man1/mysqld_safe.1.gz
/usr/share/man/man1/mysql_plugin.1.gz
/usr/share/man/man1/mysql_secure_installation.1.gz
/usr/share/man/man1/mysql_ssl_rsa_setup.1.gz
/usr/share/man/man1/mysql_tzinfo_to_sql.1.gz
/usr/share/man/man1/perror.1.gz
/usr/share/man/man1/replace.1.gz
/usr/share/man/man1/resolveip.1.gz
/usr/share/man/man1/resolve_stack_dump.1.gz
/usr/share/man/man1/zlib_decompress.1.gz
/usr/share/mysql
/usr/share/mysql/debian_create_root_user.sql
/usr/share/mysql/docs
/usr/share/mysql/docs/INFO_BIN
/usr/share/mysql/docs/INFO_SRC
/usr/share/mysql/echo_stderr
/usr/share/mysql/errmsg-utf8.txt
/usr/share/mysql/install_rewriter.sql
/usr/share/mysql/mysqld_multi.server
/usr/share/mysql/mysql_sys_schema.sql
/usr/share/mysql/mysql-systemd-start
/usr/share/mysql/mysql_test_data_timezone.sql
/usr/share/mysql/uninstall_rewriter.sql
/var
/var/lib
/var/lib/mysql-upgrade




注意上面藍色字的部份,有上面「回覆#2」提到的「/etc/init.d/mysql」和「/lib/systemd/system/mysql.service」。

================================================================================

接下來從另外一個角度來探討,待續...

7/24 15:49:40
應用擴展 工具箱
回覆: 請問mysqld問題
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 32
HP : 155 / 776
MP : 464 / 12107
EXP: 7
離線
接下來從另外一個角度來探討

================================================================================

執行


$ whereis mysqld



顯示


mysqld: /usr/sbin/mysqld /usr/share/man/man8/mysqld.8.gz



--------------------------------------------------------------------------------

執行


$ which mysqld



顯示


/usr/sbin/mysqld



--------------------------------------------------------------------------------

執行


$ dpkg -S /usr/sbin/mysqld



顯示


mysql-server-core-5.7: /usr/sbin/mysqld



表示「/usr/sbin/mysqld」是屬於「mysql-server-core-5.7」這個套件。

上面兩個指令,也可以合併成一個

也就執行下面指令


$ dpkg -S $(which mysqld)



顯示


mysql-server-core-5.7: /usr/sbin/mysqld




--------------------------------------------------------------------------------

執行


$ dpkg -L mysql-server-core-5.7 | grep mysqld



顯示


/usr/share/man/man8/mysqld.8.gz
/usr/sbin/mysqld




--------------------------------------------------------------------------------

執行


$ apt-cache show mysql-server-5.7 | grep '^Depends:'



顯示


Depends: apparmor (>= 2.10), bsdutils, initscripts, lsb-base (>= 4.1+Debian11ubuntu7), mysql-client-5.7 (>= 5.7.19-0ubuntu0.16.04.1), mysql-common (>= 5.6.22-1~), mysql-server-core-5.7 (= 5.7.19-0ubuntu0.16.04.1), passwd, perl (>= 5.6), psmisc, debconf (>= 0.5) | debconf-2.0, init-system-helpers (>= 1.18~), libc6 (>= 2.14), libevent-core-2.0-5 (>= 2.0.10-stable), libgcc1 (>= 1:3.0), liblz4-1 (>= 0.0~r127), libstdc++6 (>= 5.2), zlib1g (>= 1:1.1.4)



從上面可以了解到,安裝「mysql-server-5.7」這個套件,
也會一併安裝「mysql-server-core-5.7」這個套件。


================================================================================

其餘的請一併參考上面的回覆,以及「[索引] 套件操作實務」,

或是也可以參考

* 鳥哥的 Linux 私房菜 / 第六章、Linux 檔案與目錄管理 / 6.5 指令與檔案的搜尋
* 阿旺的 Linux 開竅手冊 / 7.3 檔案搜尋

================================================================================

以上提供參考

報告完畢


7/24 15:55:48
應用擴展 工具箱


 [無發表權] 請登錄或者註冊


可以查看帖子.
不可發帖.
不可回覆.
不可編輯自己的帖子.
不可刪除自己的帖子.
不可發起投票調查.
不可在投票調查中投票.
不可上傳附件.
不可不經審核直接發帖.