mySQL basic configuration

  • Enable remote access from any IP

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 127.0.0.1
127.0.0.1 Changed to * o 0.0.0.0 to accept connections from outside.

  • Create certificate files:

sudo mysql_ssl_rsa_setup -v

  • Create a user from anywhere (using %):

mysql> CREATE USER ‘unusuario’@’%’ IDENTIFIED BY ‘pass1234’ ;
mysql> GRANT ALL PRIVILEGES ON . TO ‘unusuario’@’%’ WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;

mysql> SELECT user FROM mysql.user;

mysql> SHOW GRANTS FOR ‘unusuario’@’%’;

  • Check connections

$ mysqladmin version

$ mysqladmin -h 192.168.2.86 –port=3306 version -u unusuario -p

  • Create sample database

mysql> CREATE DATABASE proyecto;
mysql> USE proyecto
mysql> CREATE TABLE robot (t_tobot FLOAT(20), consumo FLOAT(20), timestamp TIMESTAMP);

  • This is a reminder for Grafana

cat /etc/default/grafana-agent

go to integrations section

mysqld_exporter:
    enabled: true
    data_source_name: "unusuario:put-password-here@(localhost:3306)/"

sudo systemctl status grafana-agent.service

Batch port opening in Windows 10

I had to go back to Microsoft Batch programming language to open several ports under windows (and be able to delete those rules). Nowadays this probably could also be done using powershell but it was not needed.

@echo off
:: Apertura de puertos VersionDog en Windows 10
:: Version 1.0, 05/03/2021, deviker
:: Ejecutar como administrador (ej: segundo boton y ejectutar como administrador)
:: Para borrar reglas ejecutar este comando con el parametro -delete

SET PORTS=64001,64002,64004,64006,64003,64021,64011,64012,64010

if %1$==-delete$ goto delete

echo Aplicando reglas de apertura de puertos para VersionDog...
for %%i in (%PORTS%) do netsh advfirewall firewall add rule name= "Open port %%i" dir=in action=allow protocol=TCP localport=%%i

echo Reglas aplicadas.
netsh firewall show state
goto end

:delete
echo Borrardo reglas...
for %%i in (%PORTS%) do netsh advfirewall firewall delete rule name= "Open port %%i"
echo Reglas borradas.
netsh firewall show state

:end