The BeagleBone Black has a standard 2 GB built-in flash memory , but that can sometime be pretty close depending on the installed operating system and installed programs .
Moreover, it is quite useful to have certain applications, such as a php- based CMS to run with MySQL database on faster memory such as USB flash or an external USB hard drive .
How to add storage to a BeagleBone Black is described here Enhance Storage on the Beaglebone Black
By default , MySQL stores its databases in Debian in the folder
/var/lib/mysql . If you go to the internal memory has no more space and want to move the location to external storage media , which is actually pretty easy.
- create a folder on the external storage, for example,
- set the necessary permissions for the folder with
chown -R mysql:mysql /path-to-mountpoint/mysql/
( chown = change owner and by the -R the permissions are set recursively , ie including folders and subfolders )
- copy all files from the old directory to the new folder
cp -r /var/lib/mysql/* /path-to-mountpoint/mysql/
- adjust the configuration file of MySQL li>
To customize the configuration file open it in a text editor of your choice – such as nano.
The file is a little more complex , but the important part is this
[mysqld] # # * Basic Settings # user = mysql pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock port = 3306 basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp lc-messages-dir = /usr/share/mysql skip-external-locking
There, the entry „datadir“ is adjusted in that way, that it points to the newly created folder.
[mysqld] # # * Basic Settings # user = mysql pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock port = 3306 basedir = /usr datadir = /path-to-mountpoint/mysql/ tmpdir = /tmp lc-messages-dir = /usr/share/mysql skip-external-locking
Save the file and restart MySQL with
service mysql restart and thats it.
After moving the databases to a USB-attached hard disk, it always came to problems and errors in MySQL. Moving to an installed SD card on the other hand runs smoothly.