[root@tweety ~]# cat /etc/my.cnf.d/tweety.cnf
[mysqld]datadir=/mnt/services/DBs/mysqlsocket=/mnt/services/DBs/mysql/mysql.sock[client]socket=/mnt/services/DBs/mysql/mysql.sock
[[MySQL]]driver = weedb.mysql# The host where the database is locatedhost = localhost# The user name for logging in to the hostuser = weewx# The password for the user name. Put in quotes to guard against parsing errors.password = *****
engine: Database OperationalError exception: (2002, "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)")
[[MySQL]]
# The host where the database is locatedhost = 127.0.0.1
--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscribe@googlegroups.com.
[[MySQL]]driver = weedb.mysql# The host where the database is locatedhost = localhost
port = 3306
# The user name for logging in to the hostuser = weewx# The password for the user name. Put in quotes to guard against parsing errors.
password = ******
[root@tweety ~]# systemctl status -l weewx● weewx.service - SYSV: start and stop the weewx weather systemLoaded: loaded (/etc/rc.d/init.d/weewx; bad; vendor preset: disabled)Active: active (exited) since Tue 2017-03-14 12:29:12 EET; 999ms agoDocs: man:systemd-sysv-generator(8)Process: 1305 ExecStop=/etc/rc.d/init.d/weewx stop (code=exited, status=0/SUCCESS)Process: 1314 ExecStart=/etc/rc.d/init.d/weewx start (code=exited, status=0/SUCCESS)Mar 14 12:29:13 tweety.example.net weewx[1320]: **** File "/usr/share/weewx/weedb/mysql.py", line 38, in guarded_fnMar 14 12:29:13 tweety.example.net weewx[1320]: **** return fn(*args, **kwargs)Mar 14 12:29:13 tweety.example.net weewx[1320]: **** File "/usr/share/weewx/weedb/mysql.py", line 118, in __init__Mar 14 12:29:13 tweety.example.net weewx[1320]: **** db=database_name, **kwargs)Mar 14 12:29:13 tweety.example.net weewx[1320]: **** File "/usr/lib64/python2.7/site-packages/MySQLdb/__init__.py", line 81, in ConnectMar 14 12:29:13 tweety.example.net weewx[1320]: **** return Connection(*args, **kwargs)Mar 14 12:29:13 tweety.example.net weewx[1320]: **** File "/usr/lib64/python2.7/site-packages/MySQLdb/connections.py", line 193, in __init__Mar 14 12:29:13 tweety.example.net weewx[1320]: **** super(Connection, self).__init__(*args, **kwargs2)Mar 14 12:29:13 tweety.example.net weewx[1320]: **** TypeError: an integer is requiredMar 14 12:29:13 tweety.example.net weewx[1320]: **** Exiting.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscribe@googlegroups.com.
Mar 14 21:00:45 tweety.example.net weewx[10419]: engine: Database OperationalError exception: (2002, "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)")Mar 14 21:00:45 tweety.example.net weewx[10419]: **** Waiting 2 minutes then retrying...
[[MySQL]]driver = weedb.mysql# The host where the database is locatedhost = localhostport = 3306
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscribe@googlegroups.com.
Let me try again:
- If hostname is localhost or 127.0.0.1, but no port is supplied: use sockets.
- If hostname is localhost or 127.0.0.1, but a port is supplied: use TCP/IP.
- If hostname is anything else, use TCP/IP.
If you want to use sockets, you should not specify a port number. It only makes sense: you are not using TCP/IP, so why would it need a port number?
As far as why your server cannot connect to the mysql.sock socket, I can't say. That's a MariaDB / MySQLDB question.
I assume something has to be set in the configuration file.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscribe@googlegroups.com.
Okay, so you want to use _mysql anyway. Here are some examples.The simplest possible database connection is:
import _mysqldb=_mysql.connect()
This creates a connection to the MySQL server running on the local machine using the standard UNIX socket (or named pipe on Windows), your login name (from the USER environment variable), no password, and does not USE a database. Chances are you need to supply more information.:
db=_mysql.connect("localhost","joebob","moonpie","thangs")
This creates a connection to the MySQL server running on the local machine via a UNIX socket (or named pipe), the user name "joebob", the password "moonpie", and selects the initial database "thangs".We haven't even begun to touch upon all the parameters connect() can take. For this reason, I prefer to use keyword parameters:
db=_mysql.connect(host="localhost",user="joebob", passwd="moonpie",db="thangs")
This does exactly what the last example did, but is arguably easier to read. But since the default host is "localhost", and if your login name really was "joebob", you could shorten it to this:
db=_mysql.connect(passwd="moonpie",db="thangs")
UNIX sockets and named pipes don't work over a network, so if you specify a host other than localhost, TCP will be used, and you can specify an odd port if you need to (the default port is 3306):
db=_mysql.connect(host="outhouse",port=3307,passwd="moonpie",db="thangs")
If you really had to, you could connect to the local host with TCP by specifying the full host name, or 127.0.0.1.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+unsubscribe@googlegroups.com.