Weewx MySQL help

171 views
Skip to first unread message

dave.sp...@gmail.com

unread,
Sep 30, 2021, 10:35:49 PM9/30/21
to weewx...@googlegroups.com

Ok, Hopefully this is the last thing that I need help with on my rebuild. I have another server that is running MySQL and I am able to log into it with now issues. I have created an account for weewx. I have verified that I can log with that account. I have a DNS entry point to mysql. I have even tried using the IP of the MySQL server and still get the same results. Does anyone have any idea on why I can not connect to the server while running weewx?

 

I have attached the log and highlighted the error in red.

 

Thanks for all your help

Dave

 

ct  1 03:28:08 raspberrypi systemd[1]: Starting LSB: weewx weather system...

Oct  1 03:28:08 raspberrypi weewx[1480] INFO __main__: Initializing weewx version 4.5.1

Oct  1 03:28:08 raspberrypi weewx[1480] INFO __main__: Using Python 3.7.3 (default, Jan 22 2021, 20:04:44) #012[GCC 8.3.0]

Oct  1 03:28:08 raspberrypi weewx[1480] INFO __main__: Platform Linux-5.10.60-v7+-armv7l-with-debian-10.10

Oct  1 03:28:08 raspberrypi weewx[1480] INFO __main__: Locale is 'en_US.UTF-8'

Oct  1 03:28:08 raspberrypi weewx[1480] INFO __main__: PID file is /var/run/weewx.pid

Oct  1 03:28:08 raspberrypi weewx[1484] INFO __main__: Using configuration file /home/weewx/weewx.conf

Oct  1 03:28:08 raspberrypi weewx[1484] INFO __main__: Debug is 0

Oct  1 03:28:08 raspberrypi weewx[1484] INFO weewx.engine: Loading station type SDR (user.sdr)

Oct  1 03:28:08 raspberrypi weewx[1470]: Starting weewx weather system: weewx.

Oct  1 03:28:08 raspberrypi systemd[1]: Started LSB: weewx weather system.

Oct  1 03:28:08 raspberrypi weewx[1484] INFO user.sdr: driver version is 0.78

Oct  1 03:28:08 raspberrypi weewx[1484] INFO user.sdr: sensor map is {'outTemp': 'temperature.0010.AcuriteAtlasPacket', 'outHumidity': 'humidity.0010.AcuriteAtlasPacket', 'outBatteryStatus': 'battery.0010.AcuriteAtlasPacket', 'rain_total': 'rain_total.0010.AcuriteAtlasPacket', 'windSpeed': 'wind_speed.0010.AcuriteAtlasPacket', 'windDir': 'wind_speed.0010.AcuriteAtlasPacket'}

Oct  1 03:28:08 raspberrypi weewx[1484] INFO user.sdr: deltas is {'rain': 'rain_total', 'strikes': 'strikes_total'}

Oct  1 03:28:08 raspberrypi weewx[1484] INFO user.sdr: startup process 'sudo /usr/local/bin/rtl_433 -M utc -F json'

Oct  1 03:28:08 raspberrypi weewx[1484] INFO weewx.engine: StdConvert target unit is 0x1

Oct  1 03:28:08 raspberrypi weewx[1484] INFO user.sdr: shutdown process sudo /usr/local/bin/rtl_433 -M utc -F json

Oct  1 03:28:09 raspberrypi kernel: [ 1756.310053] r820t 12-001a: destroying instance

Oct  1 03:28:09 raspberrypi kernel: [ 1756.310646] dvb_usb_v2: 'Realtek RTL2832U reference design:1-1.1.2' successfully deinitialized and disconnected

Oct  1 03:28:28 raspberrypi weewx[1484] INFO user.sdr: timed out waiting for stderr-thread

Oct  1 03:28:31 raspberrypi kernel: [ 1779.066292] usb 1-1.1.2: dvb_usb_v2: found a 'Realtek RTL2832U reference design' in warm state

Oct  1 03:28:31 raspberrypi kernel: [ 1779.120633] usb 1-1.1.2: dvb_usb_v2: will pass the complete MPEG2 transport stream to the software demuxer

Oct  1 03:28:31 raspberrypi kernel: [ 1779.120679] dvbdev: DVB: registering new adapter (Realtek RTL2832U reference design)

Oct  1 03:28:31 raspberrypi kernel: [ 1779.120699] usb 1-1.1.2: media controller created

Oct  1 03:28:31 raspberrypi kernel: [ 1779.123765] dvbdev: dvb_create_media_entity: media entity 'dvb-demux' registered.

Oct  1 03:28:31 raspberrypi kernel: [ 1779.141830] i2c i2c-11: Added multiplexed i2c bus 12

Oct  1 03:28:31 raspberrypi kernel: [ 1779.141856] rtl2832 11-0010: Realtek RTL2832 successfully attached

Oct  1 03:28:31 raspberrypi kernel: [ 1779.141950] usb 1-1.1.2: DVB: registering adapter 0 frontend 0 (Realtek RTL2832 (DVB-T))...

Oct  1 03:28:31 raspberrypi kernel: [ 1779.141984] dvbdev: dvb_create_media_entity: media entity 'Realtek RTL2832 (DVB-T)' registered.

Oct  1 03:28:31 raspberrypi kernel: [ 1779.142268] r820t 12-001a: creating new instance

Oct  1 03:28:31 raspberrypi kernel: [ 1779.149430] r820t 12-001a: Rafael Micro r820t successfully identified

Oct  1 03:28:31 raspberrypi kernel: [ 1779.163816] rtl2832_sdr rtl2832_sdr.0.auto: Registered as swradio0

Oct  1 03:28:31 raspberrypi kernel: [ 1779.163840] rtl2832_sdr rtl2832_sdr.0.auto: Realtek RTL2832 SDR attached

Oct  1 03:28:31 raspberrypi kernel: [ 1779.163854] rtl2832_sdr rtl2832_sdr.0.auto: SDR API is still slightly experimental and functionality changes may follow

Oct  1 03:28:31 raspberrypi kernel: [ 1779.176856] Registered IR keymap rc-empty

Oct  1 03:28:31 raspberrypi kernel: [ 1779.177023] rc rc0: Realtek RTL2832U reference design as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1/1-1.1.2/rc/rc0

Oct  1 03:28:31 raspberrypi kernel: [ 1779.177233] rc rc0: lirc_dev: driver dvb_usb_rtl28xxu registered at minor = 0, raw IR receiver, no transmitter

Oct  1 03:28:31 raspberrypi kernel: [ 1779.177435] input: Realtek RTL2832U reference design as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1/1-1.1.2/rc/rc0/input14

Oct  1 03:28:31 raspberrypi kernel: [ 1779.177840] usb 1-1.1.2: dvb_usb_v2: schedule remote query interval to 200 msecs

Oct  1 03:28:31 raspberrypi kernel: [ 1779.186235] usb 1-1.1.2: dvb_usb_v2: 'Realtek RTL2832U reference design' successfully initialized and connected

Oct  1 03:28:31 raspberrypi weewx[1484] CRITICAL __main__: Database connection exception: (2002, "Can't connect to MySQL server on 'mysql' (115)")

Oct  1 03:28:31 raspberrypi weewx[1484] CRITICAL __main__:     ****  Waiting 60 seconds then retrying...

Oct  1 03:28:32 raspberrypi systemd-udevd[1516]: Process '/usr/sbin/th-cmd --socket /var/run/thd.socket --passfd --udev' failed with exit code 1.

Tom Keffer

unread,
Oct 1, 2021, 8:39:48 AM10/1/21
to weewx-user
This could be due to any number of reasons. Insufficient privilege to open up the socket, firewall issues, bad password, or even that you have not installed the MySQL server.

Can you connect by using the mysql tool? For example, for user 'weewx':

mysql -u weewx -p

But, honestly, do you need MySQL? It is much harder to administer. If you don't have experience with it, you should stick with SQLite. See the Wiki article SQLite vs MySQL.

-tk

--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/016d01d7b66d%24088feee0%2419afcca0%24%40gmail.com.
Message has been deleted
Message has been deleted

vince

unread,
Oct 1, 2021, 1:33:32 PM10/1/21
to weewx-user
(trying a third and last time - google groups deleted my first two attempts for some unknown reason)

Check your DNS settings and make sure that your pi can resolve the IP address of the hostname you defined for your database server.

dave.sp...@gmail.com

unread,
Oct 1, 2021, 5:23:56 PM10/1/21
to weewx...@googlegroups.com

Yes my pi can resolve mysql. I have even tried using the IP address and still have the same issue. I have also check iptables -L and nothing is there either on the PI or mysql server.

 

I am successful at connecting to mysql through the CLI. So it is not a password issue

 

Any other ideas?

 

Thanks

Dave

 

From: weewx...@googlegroups.com <weewx...@googlegroups.com> On Behalf Of vince
Sent: Friday, October 1, 2021 11:30 AM
To: weewx-user <weewx...@googlegroups.com>
Subject: Re: [weewx-user] Weewx MySQL help

 

I suspect it's DNS related on the LAN.   Can the raspberry resolve a host 'mysql' to the server running that ?

vince

unread,
Oct 1, 2021, 5:27:13 PM10/1/21
to weewx-user
On Friday, October 1, 2021 at 2:23:56 PM UTC-7 dave.sp...@gmail.com wrote:

dave.sp...@gmail.com

unread,
Oct 1, 2021, 6:33:23 PM10/1/21
to weewx...@googlegroups.com

I have attached a copy of the syslog file and weewx.conf file. Hopefully that will help decipher the issue that I am having with connecting to MySQL. I have redacted the password in the mysql section.

 

Litte bit more information: I am trying to make a MySQL connection. MySQL is running on Ubuntu Server 20.04 LTS. This is also a brand new server as my old server died during an upgrade

No LSB modules are available.

Distributor ID: Ubuntu

Description:    Ubuntu 20.04.3 LTS

Release:        20.04

Codename:       focal

 

I am able to cli into the mysql using cli, mysql -u weewx -p. I have check iptables -L and there are no rules for the firewall. I did check both the MySQL server and the RPi and both have no firewall rules.

 

I have run weewx with MySQL connection in the past with no issues, but that was on a much older system.

 

Thanks for any information that may help get a connection to MySQL server

 

Thanks

Dave

 

 

From: weewx...@googlegroups.com <weewx...@googlegroups.com> On Behalf Of vince
Sent: Friday, October 1, 2021 3:27 PM
To: weewx-user <weewx...@googlegroups.com>
Subject: Re: [weewx-user] Weewx MySQL help

 

On Friday, October 1, 2021 at 2:23:56 PM UTC-7 dave.sp...@gmail.com wrote:

--

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+...@googlegroups.com.

weewx.conf
mylog

Doug Jenkins

unread,
Oct 1, 2021, 7:20:22 PM10/1/21
to weewx-user
Dave & Vince:

I believe WeeWX My SQL Client uses a TCP connection over port 3306 to connect to database. To understand the problem, here is what we know:

1. You are running WeeWX on a Raspberry pi. For this illustration, lets call it CLIENT
2. You are running MySQL on a Ubuntu 20.04 server. we will call that SERVER
3. you are able to ping SERVER from CLIENT.
4. You are able to login to SERVER via mysql command line from CLIENT.

if anyone of the statements above are incorrect, please update accordingly.

Here is what I would do:

1. in your weewx.conf, change mysql to the IP address of the server.
2. on the CLIENT, ensure you can login using a TCP network connection
mysql -u <username that owns the database> -p --port=3306 --host=<IP Address of SERVER> --protocol=TCP
3. if that does not work, try sudo on the line above.

One culprit is that your MySQL server is not setup to listen for clients outside of its server. this is the reason for my questions.

Please let us know if this helps.

vince

unread,
Oct 1, 2021, 8:53:13 PM10/1/21
to weewx-user
Thanks - I recreated the original poster's issue and corrected it by changing bind-address to 0.0.0.0 in /etc/mysql/mariadb.conf.d/50-server.cnf and then restarting mariadb-server.  After that the second pi could indeed connect and write to the db.  I used the instructions at https://wiki.tinkernet.ca/index.php/WeeWX for how to set up mysql on the pi.

dave.sp...@gmail.com

unread,
Oct 2, 2021, 9:10:02 AM10/2/21
to weewx...@googlegroups.com

Thank you everyone for helping me get my issue fixed. With everyone’s input, it lead me to look more closely at MySQL server. There were several things that I modified that made it work. I changed the binding address in mysql to the IP address of the server instead of it using 127.0.0.1. Next from what I could tell, was the password encryption that mysql was using. Once I change it back to mysql_native and recreated the user, everything connect and is now working.

 

Thank you so much.

Reply all
Reply to author
Forward
0 new messages