This guide will walk you through the process of creating a secure, read-only
MySQL user specifically for connecting to the application.
Why Create a Read-Only User?
Creating a dedicated read-only user ensures:- Enhanced Security: Limits potential data manipulation risks.
- Data Integrity: Prevents accidental modifications to your database.
- Compliance: Adheres to the principle of least privilege.
Step-by-Step Guide
Follow these steps to create your MySQL read-only user:1. Create the Read-Only User
First, we’ll create a new user with a secure password:Replace ‘your_secure_password’ with a strong, unique password. Consider
using a password manager to generate and store this securely.
2. Grant Select Privileges
Next, we’ll grant the user SELECT privileges on all databases:3. Grant Additional Necessary Privileges
For Visuo.AI to function correctly, we need to grant a few more privileges:SHOW VIEW
: See the structure of viewsSHOW DATABASES
: List available databases
4. Apply the Changes
Finally, we need to apply these changes:Verifying the User Setup
To confirm that the user has been set up correctly:-
Log in to MySQL as the new read-only user:
-
Try to select data from a table:
-
Attempt to modify data (this should fail):
If you can select data but not modify it, your read-only user is set up
correctly!
Connecting to Visuo.AI
When setting up your connection in Visuo.AI:- Use the hostname of your MySQL server
- Enter ‘readonly’ as the username
- Use the secure password you set in step 1
- Specify the default database you want to analyze (if applicable)
For additional security, consider restricting the ‘readonly’ user to
specific IP addresses if Visuo.AI connects from known IP ranges.
Troubleshooting
If you encounter issues:- Ensure the user has been created successfully
- Verify that all necessary privileges have been granted
- Check that you’re using the correct hostname, username, and password in Visuo.AI
- Confirm that your MySQL server allows remote connections if Visuo.AI is hosted externally