Chapter 6 ■ Building low-Cost MysQl data nodes
Next you edit the configuration file for MySQL. In this case, you change the datadir line to read
datadir = /media/HDD/mysql. It is also a good idea to comment out the bind-address line to permit access
to MySQL from other systems on the network.
$ sudo vi /etc/mysql/my.cnf
There is one last step. You must change the owner and group to the MySQL user who was created on
installation. Here is the correct command:
$ sudo chown -R mysql:mysql /media/HDD/mysql
Now you restart MySQL.
$ sudo /etc/init.d/mysql start
You can determine whether the changes worked by connecting to MySQL, creating a new database, and
then checking to see whether the new folder was created on the external drive, as shown in Listing 6-3.
Listing 6-3. Testing the New Data Directory
pi@raspberrypi ~ $ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 43
Server version: 5.5.44-0+deb8u1 (Raspbian)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE DATABASE TESTME;
Query OK, 1 row affected (0.00 sec)
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| testme |
+--------------------+
5 rows in set (0.00 sec)
mysql> quit