fishbook/docs/setting_up.md
2020-08-04 14:35:28 +02:00

2.4 KiB

Installing a local database server

When you want to run fishbook locally you need to install a local database server (either mariaDB or mysql).

On Ubuntu or Linux mint use apt to install the server

sudo apt update
sudo apt install mariadb-server
sudo mysql_secure_installation

On Fedora use dnf

sudo dnf update
sudo dnf install mariadb-server
sudo mysql_secure_installation

On MacOS the most convenient way is to use homebrew see also mariadb documentation

brew install mariadb
mysql.server start
brew services start mariadb  # to automatically start the server upon boot

On Windows you probably need to download an installer...

Upon installation you should be able to log into the database as root without a password.

mysql -u root 

To allow datajoint to store stuff on the server you need to:

  1. Create a database on the server.
  2. Add a user and grant this user read and write access.

Creating a database

At the moment fishbook assumes that your database is called fish_book. To create it log into the server

mysql -u root -p

And and execute the following commands

MariaDB [(none)]> CREATE DATABASE fish_book CHARACTER SET = utf8;
MariaDB [(none)]> GRANT ALL ON fish_book.* TO 'foo'@'localhost' IDENTIFIED BY 'password';
MariaDB [(none)]> FLUSH PRIVILEGES;

The first command creates the empty database and sets the Character set to utf8. This is important at least when it comes to fishbook. The second row creates a user foo and grants that user all rights on all tables of fish_book. So far foo can only log in from the local machine. In order to grant access also from outsides you need to issue a second command:

MariaDB [(none)]> GRANT ALL ON fish_book.* TO 'foo'@'%' IDENTIFIED BY 'password';
MariaDB [(none)]> FLUSH PRIVILEGES;

From localhost you should now be able to log into the fish_book database by

mysql fish_book -u foo -p

From outsides use

mysql fish_book -h yourhost.yourdomain -u foo -p

Things to remember

  • Database engine must be InnoDB, which is default in MariaDB
  • OperationalError: (1071, 'Specified key was too long; max key length is 3072 bytes') Caused by a wrong character set check that it is set to utf8:
ALTER DATABASE `fish_book` CHARACTER SET utf8;