MySQL for the Internet of Things

(Steven Felgate) #1
Chapter 6 ■ Building low-Cost MysQl data nodes

Once the installation is complete, you should be able to start the MySQL server as follows. If you see
errors such as the following, you may need to do some extra work. I saw this on at least one Galileo board
after an aborted installation. You may not need these steps, but I include them in case you get stuck by this
issue. What happened was the installation failed before it created the special user mysql, which is common
for most Linux installations. But again, it is easy to fix.


$ /etc/init.d/mysqld start
$ 010101 00:27:46 mysqld_safe Logging to '/var/log/mysqld.err'.
chown: unknown user mysql
010101 00:27:46 mysqld_safe Starting mysqld daemon with databases from /var/mysql
010101 00:27:47 mysqld_safe mysqld from pid file /var/lib/mysql/mysqld.pid ended


To fix this, simply create the mysql user as follows and start the server again. If you’d like to read
more about this process, see the preconfiguration steps in the source code installation section in the
online MySQL reference manual (http://dev.mysql.com/doc/refman/5.6/en/installing-source-
distribution.html).


$ groupadd mysql
$ useradd -r -g mysql mysql
$ chown -R mysql /var/lib/mysql
$ chgrp -R mysql /var/lib/mysql
$ mysql_install_db --user=mysql
$ /etc/init.d/mysqld start


Configuring the Hard Drive


Configuring the hard drive on the Galileo is, once again, similar to the other platforms. Since the platform is
a bit different, I will walk you through the process.
Begin by plugging the USB drive into the USB port. When the drive is recognized (the access LED
may blink a few times and then go solid), execute fdisk much like we did on the Raspberry Pi to create a
partition, mkfs to format, and then mount the drive. Finally, set up the drive using the same commands as
we used on the Raspberry Pi to make the mount persistent and transfer the MySQL database datadir to the
drive as shown previously.


DOeS It Matter What VerSION OF MYSQL I USe?


you may be wondering about the version of MysQl you should use. while the latest version of MysQl
is 5.7, it is unlikely you will find this version in the package list or repositories for the linux and similar
operating systems for boards like those described here. Fortunately, most packages and repositories
have either MysQl 5.1 or 5.5 available, which should be sufficient for most iot solutions, and you are
unlikely to need the latest features of MysQl.

however, if you do need the latest features for compatibility or conformity, you may need to download
the source code directly from oracle and build the installation locally. or you could search for a
precompile binary or even an installation package for your platform. while they’re rare, i have
encountered these packages from time to time. don’t be afraid to ask people on a support forum for
your board for help. Chances are someone out there has already created what you need.
Free download pdf