From fcb5889464de7804cd126656b002efd88879e109 Mon Sep 17 00:00:00 2001
From: Tom Keffer
This section applies only to those who wish to use the MySQL database, instead of the default SQLite - database. +
+ This section applies only to those who wish to use the MySQL database, instead of the default SQLite + database. It assumes that you have a working version of MySQL or MariaDB installed.
+Install the client libraries. How to do this depends on your operating system. Use the table below as + a guide. +
-First, verify that the MySQLdb python package is installed:
+sudo apt install mysql-client +sudo apt install python3-mysqldb+
sudo yum install MySQL-python ++
sudo zypper install python3-mysqlclient+
python -c "import MySQLdb"-
If this results in an import error
- -ImportError: No module named MySQLdb- -
then install the MySQLdb package. For example, on Debian systems: -
- -sudo apt-get install python-mysqldb- -
Next, change the WeeWX configuration to use MySQL instead of SQLite. In the WeeWX configuration file, change - the [[wx_binding]] section to point to the MySQL - database, archive_mysql, instead of the SQLite database archive_sqlite. -
-After the change, it will look something like this (change highlighted): -
-+
+ Change the WeeWX configuration to use MySQL instead of SQLite. In the WeeWX configuration file, + change the [[wx_binding]] section to point to + the MySQL database, archive_mysql, instead of the SQLite database archive_sqlite. +
+After the change, it will look something like this (change highlighted): +
+
[[wx_binding]]
# The database should match one of the sections in [Databases]
database = archive_mysql
@@ -913,27 +945,36 @@ sudo /etc/init.d/weewx restart
# The schema defines to structure of the database contents
schema = schemas.wview_extended.schema
- Assuming that you want to use the default database configuration, the [[MySQL]] section should look something like this: -
-[[MySQL]] +
+ Configure the MySQL host and credentials. Assuming that you want to use the default database + configuration, the [[MySQL]] section should look + something like this: +
+ [[MySQL]]
driver = weedb.mysql
host = localhost
user = weewx
password = weewx
- This assumes user weewx has the password weewx. Adjust as - necessary. -
- -- You will need to give the necessary permissions for the database weewx to whatever - MySQL user you choose, by default, user weewx. Here are the necessary minimum - permissions, again assuming user weewx with password weewx. Adjust as necessary.: -
-mysql> CREATE USER 'weewx'@'localhost' IDENTIFIED BY 'weewx'; +This assumes user weewx has the password weewx. + Adjust as necessary. +
+
+ Configure MySQL to give the necessary permissions for the database weewx to + whatever MySQL user you choose. Here are the + necessary minimum permissions, again assuming user weewx with password + weewx. Adjust as necessary.: +
+mysql> CREATE USER 'weewx'@'localhost' IDENTIFIED BY 'weewx'; mysql> GRANT select, update, create, delete, insert, drop ON weewx.* TO weewx@localhost;+