我正在開發Rails v2.3應用程序。並使用MySQL v5.1。停止啓動數據庫
我需要停止在我rake任務之一開始 mysql數據庫,但我不知道如何實現這個東西,可能有人幫助我嗎?
namespace :db do
task :some_db_task => :environment do
#shut down mysql
...
#start mysql
end
end
順便說一句,我開發上Ubuntu的機。
----------------------- update --------------------- -------
我試過exec "/etc/init.d/mysql stop"
,我得到了以下錯誤消息:
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql stop
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) utility, e.g. stop mysql
stop: Rejected send message, 1 matched rules; type="method_call", sender=":1.78" (uid=1000 pid=6331 comm="stop) interface="com.ubuntu.Upstart0_6.Job" member="Stop" error name="(unset)" requested_reply=0 destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init"))
我試圖/etc/init.d/mysql stop
還命令行上,相同的錯誤加薪,
通過遵循錯誤消息的說明,然後我嘗試service mysql stop
,我收到了一個新的錯誤消息:
stop: Rejected send message, 1 matched rules; type="method_call", sender=":1.79" (uid=1000 pid=6343 comm="stop) interface="com.ubuntu.Upstart0_6.Job" member="Stop" error name="(unset)" requested_reply=0 destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init"))
爲什麼我不能停止mysql?
---------------更新2 -------------------------
我意識到,即使上面提到的錯誤消息顯示,sudo /etc/init.d/mysql stop
實際上完成其作業。 MySQL 通過此命令得到停止,同時消息提升。
請檢查我的更新,現在的問題似乎我無法停止mysql ... – Mellon
看到我的更新^^ – Michael
我試圖更新運行「sudo服務mysql停止」,現在我收到錯誤消息「停止:未知實例:」 – Mellon