Saturday, February 20, 2010

Installing MySQL on the TonidoPlug

An important element of the Smart Energy System that I am building is a local and remote database to store telemetry packets, processed data, and control / status strings. For remote storage I plan to use Amazon's SimpleDB service (which I have tested previously on the PlugPC), and for local storage I plan to use a MySQL database structure. So my next job is to install MySQL on my Plug.

I first tried installing MySQL 5.0, but this was a complete disaster and the installation kept finding it's way into a infinite error loop... this was removed tout de suite. The problems I saw during the installation of 5.0 might be why version 5.1 emerged! Anyway, I tried again with MySQL 5.1. After SSHing in to my Plug, to install 5.1 I executed:

apt-get install mysql-client-5.1 mysql-server-5.1 (these just happened to be the versions available on the repository I am using - as of writing version 5.5 is available)

The installation process ran without incident, but for some reason no password was created during installation and I could not gain access to the MySQL interactive mode. The following sequence of commands fixed this particular problem.

First, try to stop the MySQL daemon:

/etc/init.d/mysql stop

Followed by:

mysqld_safe --skip-grant-tables & (which is the recommended way to start MySQL)
mysql -u root -p (to enter as 'root' - you will be prompted for your system 'root' password. If successful you will now be in MySQL interactive mode)
mysql client - mysql - root
use mysql
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root' (should probably choose a MySQL 'root' password that is different from your system 'root' password)

Now, we're ready to start creating tables and fields, and storing and quering data... I'll save this treat for another day when I have had time to decide what table and fields I need for my SES.

To launch MySQL from the command line:

mysql -u root -p (you will then be prompted for your MySQL 'root' password)

The MySQL documentation for getting started is available if you want to start playing right away.

1 comment:

  1. Seems like we have similar ideas. I want to set up a wrapper that intercepts the Current Cost EnviR data stream and puts it into mySQL, and use that as one source of truth to manage reporting from - as a start. Using the TonidoPlug and currently the SmartNowBrain app on it. Might bounce you a few comments as things proceed.. ;-)

    ReplyDelete