Configure a MySQL connection to Florentine.ai via MySQL shell
This guide will take you through all the necessary steps needed to connect a MySQL database running on a remote server to Florentine.ai via the MySQL shell:
Important
Your MySQL instance must be running on a remotely accessible server. Florentine.ai is a cloud-based service and cannot connect to localhost or 127.0.0.1.
Create a readonly user
Start by connecting to your database via the MySQL shell on your server. You might have to modify the command, i.e. add your own host and/or a different port, see Connecting to the MySQL Server in the MySQL docs in case you need help:
mysql --user root --password --host localhost --port 3306Run the following commands to create a read-only user with access restricted to the Florentine.ai IP addresses 167.99.246.57 and 209.38.238.253.
Replace <db_username> with a username (e.g. florentine) and <db_password> with a strong password. MySQL requires separate entries for each IP, make sure that you use the same username and password for both IPs.
Also copy the username and password because you need them for the connection string later:
CREATE USER '<db_username>'@'167.99.246.57' IDENTIFIED BY '<db_password>';
CREATE USER '<db_username>'@'209.38.238.253' IDENTIFIED BY '<db_password>';Grant database access
Grant read-only access to the specific database. Replace <db_name> with your actual database name and <db_username> with the username created in the previous step:
GRANT SELECT ON <db_name>.* TO '<db_username>'@'167.99.246.57';
GRANT SELECT ON <db_name>.* TO '<db_username>'@'209.38.238.253';Grant network access
Besides a user with database access, your server's firewall needs to grant network access to the Florentine.ai IPs as well.
If you are using a different port you need to replace 3306 with your actual port number.
Using UFW (Ubuntu/Debian)
sudo ufw allow from 167.99.246.57 to any port 3306 proto tcp
sudo ufw allow from 209.38.238.253 to any port 3306 proto tcpUsing iptables
sudo iptables -A INPUT -s 167.99.246.57 -p tcp --dport 3306 -j ACCEPT
sudo iptables -A INPUT -s 209.38.238.253 -p tcp --dport 3306 -j ACCEPTMake new iptables rules persistent on Debian/Ubuntu:
sudo iptables-save > /etc/iptables/rules.v4Make new iptables rules persistent on CentOS/RHEL/Fedora/Rocky/AlmaLinux:
sudo iptables-save > /etc/sysconfig/iptablesConfigure MySQL server
Additionally, make sure that your MySQL server is configured to accept connections from remote hosts. Check your my.cnf or mysql.conf.d/mysqld.cnf and ensure bind-address is not set to 127.0.0.1:
[mysqld]
bind-address = 0.0.0.0If you changed the bind-address, restart the MySQL service:
sudo systemctl restart mysqlCreate the connection string
You should now be able to create the connection string you need to add in your Florentine.ai account. The structure of the connection string looks like this:
mysql://<db_username>:<db_password>@<domain>:<port>/<db_name>Now you only need to replace <db_username>, <db_password>, <domain>, <port> and <db_name> with your settings, so your final connection string should look comparable to this:
mysql://florentine:[email protected]:3306/samplesEnter your final connection string on the connect page in your Florentine.ai account, click on Connect and if everything is configured correctly you should see a list of the tables inside your database.