From fcb5889464de7804cd126656b002efd88879e109 Mon Sep 17 00:00:00 2001 From: Tom Keffer Date: Mon, 23 Mar 2020 07:41:21 -0700 Subject: [PATCH] Updated configuration instructions for MySQL. --- docs/usersguide.htm | 113 ++++++++++++++++++++++++++++++-------------- 1 file changed, 77 insertions(+), 36 deletions(-) diff --git a/docs/usersguide.htm b/docs/usersguide.htm index 212f3535..103293d5 100644 --- a/docs/usersguide.htm +++ b/docs/usersguide.htm @@ -18,6 +18,7 @@ create_toc(level); // Create a click on the first tab to get things started. $('#dir-layout-table .tab')[0].click(); + $('#mysql-client-tabs .tab')[0].click(); }) @@ -877,32 +878,63 @@ sudo /etc/init.d/weewx restart

-

Configuring MySQL

+

Configuring MySQL / MariaDB

-

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.

+
    +
  1. +

    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
    +
    +
    +
  2. -
    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): -

    -
    +            
  3. +

    + 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
  4. -

    Assuming that you want to use the default database configuration, the [[MySQL]] section should look something like this: -

    -
        [[MySQL]]
    +            
    +
    +            
  5. +

    + 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. +

    +
  6. +
  7. +

    + 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;
    +
  8. +

Compatibility with wview