如何使用mysql配置gammu-smsd

时间:2018-08-19 02:42:40

标签: mysql gammu

我试图启动gammu sms服务,当我使用简单的存档运行它时,它运行良好,但是当我尝试使用mysql数据库运行它时,它显示此错误:

错误代码:2002,错误:无法通过套接字'/var/run/mysqld/mysqld.sock'(2)连接到本地MySQL服务器

重新启动gammu-sms,显示此消息:

user2@Lubuntu18:~$ service gammu-smsd restart
user2@Lubuntu18:~$ service gammu-smsd status
● gammu-smsd.service - SMS daemon for Gammu
   Loaded: loaded (/lib/systemd/system/gammu-smsd.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2018-08-18 20:55:21 -04; 2min 52s ago
     Docs: man:gammu-smsd(1)
  Process: 19001 ExecStopPost=/bin/rm -f /var/run/gammu-smsd.pid (code=exited, status=0/SUCCESS)
  Process: 18999 ExecStart=/usr/bin/gammu-smsd --pid=/var/run/gammu-smsd.pid --daemon (code=exited, status=0/SUCCESS)
 Main PID: 19000 (code=exited, status=2)

ago 18 20:55:21 Lubuntu18 systemd[1]: Starting SMS daemon for Gammu...
ago 18 20:55:21 Lubuntu18 systemd[1]: gammu-smsd.service: Can't open PID file /var/run/gammu-smsd.pid (yet?) after start: No s
ago 18 20:55:21 Lubuntu18 systemd[1]: Started SMS daemon for Gammu.
ago 18 20:55:21 Lubuntu18 systemd[1]: gammu-smsd.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
ago 18 20:55:21 Lubuntu18 systemd[1]: gammu-smsd.service: Failed with result 'exit-code'.

日志文件gammu smsd显示如下:

Sat 2018/08/18 20:55:21 gammu-smsd[19000]: Error connecting to database!
Sat 2018/08/18 20:55:21 gammu-smsd[19000]: Error code: 2002, Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Sat 2018/08/18 20:55:21 gammu-smsd[19000]: Initialisation failed, stopping Gammu smsd: Database connection timeout. (DB_TIMEOUT[78])
Sat 2018/08/18 20:55:21 gammu-smsd[19000]: Stopping Gammu smsd: Sin error. (NONE[1])
     Docs: man:gammu-smsd(1)
  Process: 19001 ExecStopPost=/bin/rm -f /var/run/gammu-smsd.pid (code=exited, status=0/SUCCESS)
  Process: 18999 ExecStart=/usr/bin/gammu-smsd --pid=/var/run/gammu-smsd.pid --daemon (code=exited, status=0/SUCCESS)
 Main PID: 19000 (code=exited, status=2)

ago 18 20:55:21 Lubuntu18 systemd[1]: Starting SMS daemon for Gammu...
ago 18 20:55:21 Lubuntu18 systemd[1]: gammu-smsd.service: Can't open PID file /var/run/gammu-smsd.pid (yet?) after start: No s
ago 18 20:55:21 Lubuntu18 systemd[1]: Started SMS daemon for Gammu.
ago 18 20:55:21 Lubuntu18 systemd[1]: gammu-smsd.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
ago 18 20:55:21 Lubuntu18 systemd[1]: gammu-smsd.service: Failed with result 'exit-code'.

/ etc / gammu-smsdrc是:

# Configuration file for Gammu SMS Daemon

# Gammu library configuration, see gammurc(5)
[gammu]
device = /dev/ttyUSB0
name = USB Qualcomm__Incorporated Qualcomm_CDMA_Technologies_MSM
connection = at
logfile = /home/ruser2/gammu.log
logformat = textall

# SMSD configuration, see gammu-smsdrc(5)
[smsd]
runonreceive = /opt/lampp/htdocs/kalkun/scripts/daemon.sh
service = sql
Driver = native_mysql
PIN= 1234
logfile = /home/user2/gammusmsd.log
# Increase for debugging information
debuglevel = 0
user = kalkun
password = kalkun
pc = localhost
database = kalkun

我使用Lubuntu:

18.04

xampp 5.6.30

PHP版本5.6.23


有什么办法可以帮助我吗?非常感谢

1 个答案:

答案 0 :(得分:0)

您的用户没有权限,您以user2@Lubuntu18的身份开始。

尝试以root用户身份启动gammu-smsd,或向用户2添加权限dialout

sudo gammu-smsd -d --user gammu --group dialout