1. 程式人生 > >linux - mysql:啟動 mysql

linux - mysql:啟動 mysql

啟動mysql

第一種:

/etc/rc.d/init.d/mysqld start

/etc/rc.d/init.d/mysqld stop

第二種:使用service 啟動、關閉MySQL服務

service mysql start

service mysql stop

service mysql restart

 

異常

service mysql start 出錯

出錯內容:mysql: unrecognized service或mysql: 未被識別的服務

解決方法:

[[email protected] ~]# service mysql start

mysql: unrecognized service

[[email protected] ~]# service mysql restart

mysql: unrecognized service

[[email protected] ~]# rpm -q mysql   查詢發現mysql已經正常安裝

mysql-5.1.52-jason.1

[[email protected] ~]# /etc/rc.d/init.d/mysqld start  直接啟動沒問題

Starting mysqld:  [  OK  ]

[[email protected]

~]# ls  /etc/rc.d/init.d/mysqld  -l

-rwxr-xr-x 1 root root 5509 Dec 18 02:31 /etc/rc.d/init.d/mysqld

[[email protected] ~]# chkconfig mysqld on 設定mysql開機啟動

[[email protected] ~]# chmod 755 /etc/rc.d/init.d/mysqld  修改mysqld執行許可權

[[email protected] ~]# service mysqld start  搞定

Starting mysqld:  [  OK  ]

[[email protected] ~]# service mysqld start

Starting mysqld:  [  OK  ]

[[email protected] ~]# service mysqld status

mysqld (pid 9487) is running...

 

Mysql啟動失敗

問題描述:Another MySQL daemon is already running.

原因:多個Mysql程序使用了同一個socket

解決方案一:

service mysqld stop//停止mysql

mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak//修改名稱

service mysqld start//啟動mysql

解決方案二:

ps -A //檢視所有程序

killall -9 *** //殺死正在執行的mysql程序