Database

This chapter is about installing a SQL database server, which is needed by Pixelfed.

Install

After checking that the system is up to date, run:

sudo apt install -y mysql-server
sudo systemctl start mysql.service

Configure

Access to MySQL command line:

sudo mysql

Copy/paste this line and validate:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
quit

Secure install

sudo mysql_secure_installation

We answer a serie of questions, validating each time with Enter.
Change at least the blinking examples:

  • The password is password
  • y to validate password component
  • 2 for strong password policy
  • y to change root password
  • new-root-password
  • y to continue with the password
  • y to remove anonymous users
  • y to disallow root login remotely
  • y to remove test database
  • y to reload privilege tables

Reconnect:

mysql -u root -p

Password is new-root-password.

ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;

Admin user

Create another MySQL "superuser" to avoid using MySQL root in the future:

CREATE USER 'leguellec'@'localhost' IDENTIFIED BY 'superuser-password';
GRANT ALL PRIVILEGES ON *.* TO 'leguellec'@'localhost' WITH GRANT OPTION;

Pixelfed database

Create a Pixelfed database:

CREATE DATABASE pixelfed_fediverse_ovh;

Create a MySQL dedicated user:

CREATE USER 'user_pixelfed'@'localhost' IDENTIFIED BY 'user-password';
GRANT ALL PRIVILEGES ON pixelfed_fediverse_ovh.* TO 'user_pixelfed'@'localhost';
FLUSH PRIVILEGES;
quit