Better Stack MySQL logging

Start logging in 2 minutes

What you would like to collect from your MySQL?

Collect logs & metrics

Collect logs and metrics from your MySQL instance using Vector  and Prometheus mysqld exporter .

1. Set up MySQL exporter

Create a dedicated MySQL user for Vector to securely scrape metrics:

Log in to MySQL
mysql -u root -p
Create a MySQL user
CREATE USER 'better_stack_metrics'@'localhost' IDENTIFIED BY '$YOUR_PASSWORD';
GRANT PROCESS, REPLICATION CLIENT, SHOW DATABASES ON *.* TO 'better_stack_metrics'@'localhost';
GRANT SELECT ON performance_schema.* TO 'better_stack_metrics'@'localhost';
GRANT SELECT ON mysql.user TO 'better_stack_metrics'@'localhost';

Fill in your password

Replace $YOUR_PASSWORD with password of your choice.

Flush & exit
FLUSH PRIVILEGES;
exit;

Create /etc/mysqld_exporter.cnf config file using MySQL user password you've just set:

/etc/mysqld_exporter.cnf
[client]
user=better_stack_metrics
password=$YOUR_PASSWORD

2. Install MySQL exporter

Install latest mysqld exporter:

Install mysqld exporter
curl -sSL https://logs.betterstack.com/install/mysqld_exporter | sudo -E bash

3. Run exporter

Start the MySQL exporter:

Linux macOS
systemctl start mysqld_exporter
launchctl start com.prometheus.mysqld_exporter

4. Set up Vector

Select your platform:

Ubuntu • Debian

Install and configure Vector  on Ubuntu or Debian:

Set up Vector
curl -sSL https://logs.betterstack.com/setup-vector/mysql_with_metrics/$SOURCE_TOKEN \
  -o /tmp/setup-vector.sh && \
  bash /tmp/setup-vector.sh

Curious about what the script does?

  • Installs Vector using official package.
  • Configures Vector for your Better Stack source.
  • Enables and restarts Vector.

The script will ask for confirmation before making any changes.

You should see your logs in Better Stack → Live tail .

Collect only logs

Collect logs from your MySQL database using Vector.

Select your platform:

Ubuntu • Debian

Install and configure Vector  on Ubuntu or Debian:

Set up Vector
curl -sSL https://logs.betterstack.com/setup-vector/mysql/$SOURCE_TOKEN \
  -o /tmp/setup-vector.sh && \
  bash /tmp/setup-vector.sh

Curious about what the script does?

  • Installs Vector using official package.
  • Configures Vector for your Better Stack source.
  • Enables and restarts Vector.

The script will ask for confirmation before making any changes.

You should see your logs in Better Stack → Live tail .

Need help?

Please let us know at hello@betterstack.com.
We're happy to help! 🙏

Additional information

Looking for manual instructions to set up Vector?

Find step-by-step instructions in our dedicated Vector guide.