Skip to main content
MySQL is one of the world’s most popular open-source relational databases, powering millions of web applications. Queryly provides full support for connecting to and managing MySQL databases.

Connection String Format

The standard MySQL connection string format:
Server=localhost;Database=mydb;User=root;Password=secret

Connection Examples

Standard Local Connection

# Basic local connection
Server=localhost;Database=myapp;User=root;Password=mypass

# With explicit port (default is 3306)
Server=localhost;Port=3306;Database=myapp;User=root;Password=mypass

# Using IP address
Server=127.0.0.1;Database=myapp;User=root;Password=mypass
Default MySQL port is 3306. You can omit the Port parameter if using the default.

Adding a MySQL Connection

Interactive Mode

queryly connect add
Example session:
$ queryly connect add
Enter connection name: ProductionMySQL
Select database type: MySQL
Enter connection string: Server=localhost;Database=myapp;User=root;Password=mypass
 Connection test successful!
 Connection 'ProductionMySQL' saved

Supported Features

Connection Management - Add, test, list, and remove connections
Schema Exploration - List tables and view structures
Table Browsing - View table data with proper type handling
Query Execution - Run MySQL-specific SQL queries
Data Export - Export tables to CSV or JSON formats

Port Configuration

Default Port

MySQL uses port 3306 by default. You can omit the port in your connection string:
Server=localhost;Database=myapp;User=root;Password=mypass

Custom Port

If your MySQL server runs on a different port:
Server=localhost;Port=3307;Database=myapp;User=root;Password=mypass

Checking MySQL Port

# On the MySQL server
sudo netstat -tlnp | grep mysql

# Or check MySQL configuration
mysql -u root -p -e "SHOW VARIABLES LIKE 'port';"

Connection Options

UTF-8 Support

# Use utf8mb4 for full Unicode support (including emojis)
Server=localhost;Database=myapp;User=root;Password=mypass;CharSet=utf8mb4

# Legacy utf8 (3-byte only)
Server=localhost;Database=myapp;User=root;Password=mypass;CharSet=utf8
Always use utf8mb4 for new applications. It supports the full Unicode character set, including emojis and special characters.

Authentication

Username/Password

# Root user
Server=localhost;Database=myapp;User=root;Password=mypass

# Regular user
Server=localhost;Database=myapp;User=appuser;Password=apppass

# User with special characters
Server=localhost;Database=myapp;User=app@host;Password=p@ssw0rd!
Avoid using the root account for applications. Create dedicated users with limited permissions.

MySQL-Specific Features

Data Type Support

Queryly handles MySQL’s data types:
  • Numeric: int, bigint, decimal, float, double
  • Text: varchar, text, char, mediumtext, longtext
  • Date/Time: datetime, timestamp, date, time, year
  • Binary: blob, mediumblob, longblob, binary, varbinary
  • JSON: json (MySQL 5.7+)
  • Spatial: geometry, point, linestring, polygon
  • Enum/Set: enum, set

Query Examples

queryly data query ProductionMySQL

# Select queries
SQL> SELECT * FROM users LIMIT 10;
SQL> SELECT COUNT(*) FROM orders;
SQL> SELECT name, email FROM customers WHERE created_at > '2024-01-01';

Common Workflows

# Add connection
queryly connect add
# name: MyMySQL
# type: MySQL
# connection string: Server=localhost;Database=myapp;User=root;Password=mypass

# Test connection
queryly connect test MyMySQL

# List all tables
queryly schema list MyMySQL

Troubleshooting

Error: Unable to connect to any of the specified MySQL hostsSolutions:
  • Verify MySQL is running: sudo systemctl status mysql
  • Check the port: sudo netstat -tlnp | grep 3306
  • Verify bind-address in /etc/mysql/my.cnf (use 0.0.0.0 for remote access)
  • Check firewall rules
# Start MySQL
sudo systemctl start mysql

# Check if it's listening
sudo ss -tlnp | grep 3306
Error: Access denied for user 'root'@'localhost'Solutions:
  • Verify username and password
  • Check user privileges
  • Ensure user has access to the database
# Reset root password
sudo mysql
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';
mysql> FLUSH PRIVILEGES;

# Grant privileges
mysql> GRANT ALL PRIVILEGES ON myapp.* TO 'appuser'@'localhost';
mysql> FLUSH PRIVILEGES;
Error: Unknown database 'myapp'Solutions:
  • Verify database name (case-sensitive on Linux)
  • Create the database if needed
# List databases
mysql -u root -p -e "SHOW DATABASES;"

# Create database
mysql -u root -p -e "CREATE DATABASE myapp;"

# Or in MySQL prompt
mysql -u root -p
mysql> CREATE DATABASE myapp CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Error: Too many connectionsSolutions:
  • Close unused connections
  • Increase max_connections in my.cnf
  • Check for connection leaks
# Check current connections
mysql -u root -p -e "SHOW PROCESSLIST;"

# Check max connections
mysql -u root -p -e "SHOW VARIABLES LIKE 'max_connections';"

# Set max connections (requires restart)
# Edit /etc/mysql/my.cnf:
# [mysqld]
# max_connections = 200
Error: SSL connection errorSolutions:
  • Use SslMode=Preferred or SslMode=None for local development
  • Verify SSL is enabled on the server
  • Check certificate paths
# For local development
Server=localhost;Database=myapp;User=root;Password=mypass;SslMode=None

# Check SSL status
mysql -u root -p -e "SHOW VARIABLES LIKE 'have_ssl';"

Best Practices

Use utf8mb4 for character set (full Unicode support)
Create dedicated users - don’t use root for applications
Enable SSL for remote connections
Connection pooling - enabled by default for better performance
Regular backups - use mysqldump for database backups
Avoid:
  • Using the root account for application connections
  • Passwordless connections in production
  • Storing credentials in plain text
  • Leaving default ports open to the internet

Working with Commands

MySQL works with all Queryly commands:
# Connection management
queryly connect add
queryly connect list
queryly connect test MyMySQL
queryly connect remove MyMySQL

# Schema exploration
queryly schema list MyMySQL
queryly schema info MyMySQL users
queryly schema tree MyMySQL

# Data operations
queryly data browse MyMySQL users
queryly data query MyMySQL
queryly data export MyMySQL users csv
queryly data export MyMySQL users json

Command Reference

See the complete command reference for all available options

Next Steps

Schema Exploration

Learn how to explore MySQL schemas

Data Operations

Browse and query table data

Providers Overview

Compare all database providers

Connection Management

Manage your database connections

Build docs developers (and LLMs) love