Recommended Free Tools
The safest pattern is to keep MariaDB private on the VPS, connect from Python through the local Unix socket or loopback, use a separate least-privilege database account, parameterize every value, and commit or roll back each write explicitly. For backups, use mariadb-dump for logical exports or mariadb-backup for physical copies, then move the backup off the server and regularly test a restore.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
What you need before writing Python code
This guide assumes a Linux VPS where you control the operating system and MariaDB service. Install MariaDB from your distribution’s supported repository or the installation instructions for the MariaDB release you intend to run. Package names, repository setup, authentication defaults, and configuration paths differ between distributions, so verify them against the current server documentation before production deployment.
As an Amazon Associate I earn from qualifying purchases.
- A running MariaDB Server instance.
- Python 3 and a project virtual environment.
- The official
mariadbConnector/Python package, installed in that virtual environment. - An application database and a database account created specifically for the application.
- A plan for firewalling, credentials, backups, and restore testing.
MariaDB Connector/Python is MariaDB’s official client for Python. It follows Python DB API 2.0 (PEP 249), so familiar connection, cursor, parameter, transaction, and fetch patterns apply. Check the connector’s current release and parameter-style documentation when installing or upgrading; defaults and supported behavior can change between major versions.
Create a database and a restricted application account
Do not put the MariaDB root password in application code. Log in administratively once, create the database, create an account whose host component matches the way the application connects, and grant only the operations the application needs.
#1 Best Overall
- [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
- [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
- [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
- [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
- [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
sudo mariadb
CREATE DATABASE app_db
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
CREATE USER 'app_user'@'localhost'
IDENTIFIED BY 'generate-a-long-unique-secret';
GRANT SELECT, INSERT, UPDATE, DELETE
ON app_db.* TO 'app_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
The account 'app_user'@'localhost' is distinct from 'app_user'@'192.0.2.10' or 'app_user'@'%'. MariaDB evaluates both username and host, which lets you restrict a remote account to one expected source address. Avoid a wildcard host unless you have a specific, controlled reason and compensating network controls. Add schema-change privileges such as CREATE or ALTER only to a separate migration account, not to the runtime account.
Define a table that can be queried efficiently
Use explicit data types, a primary key, and indexes that match real lookup patterns. This example stores short text notes and records creation and modification times.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →sudo mariadb app_db
CREATE TABLE notes (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
body TEXT NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id),
INDEX ix_notes_created_at (created_at)
) ENGINE=InnoDB;
EXIT;
InnoDB supports transactions and is the usual choice for application tables. Add indexes based on predicates you actually use; every extra index consumes storage and makes writes more expensive. Keep schema changes in version-controlled migration files rather than issuing ad-hoc changes from the web process.
Install Connector/Python in an isolated environment
-
Create and activate a virtual environment in the application directory:
python3 -m venv .venv . .venv/bin/activate -
Install the official package and record the resolved version:
Rank #2
SaleSmart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)- 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
- 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
- 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
- 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
- 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
python -m pip install --upgrade pip python -m pip install mariadb python -m pip freeze > requirements.lock.txt -
Pin and review the connector version for deployment. Confirm its supported Python versions, system-library requirements, placeholder syntax, and TLS options in the documentation for the installed major version.
Free tools Windows power users keep installed
One-click scans. No signup required.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Keep the password in a secret manager, protected environment variable, or root-readable configuration file outside the repository. Never commit a live password or print connection settings in exception logs.
Connect locally through a Unix socket or loopback
A process running on the same VPS normally should not traverse the public network. Use localhost with the connector’s Linux socket autodetection, specify the detected socket path, or use loopback such as 127.0.0.1. The connector reference documents distribution-specific socket paths and the keyword arguments available for host, port, socket, timeouts, and database selection. The default TCP port is 3306.
import os
import mariadb
conn = mariadb.connect(
host=os.getenv("DB_HOST", "localhost"),
user=os.environ["DB_USER"],
password=os.environ["DB_PASSWORD"],
database=os.getenv("DB_NAME", "app_db"),
# port=3306, # use when TCP is intentional
# unix_socket="/run/mysqld/mysqld.sock", # use the path on your distro
connect_timeout=5,
)
If localhost fails but 127.0.0.1 works, the difference is usually socket discovery or account host matching. If the socket path is known, configure it explicitly rather than opening MariaDB externally just to work around a local configuration problem.
Use one safe CRUD transaction pattern
Connector/Python exposes cursors for statements and transaction methods on the connection. Values belong in a separate parameter sequence, never concatenated into SQL text. The exact placeholder styles accepted by your installed connector major version should be confirmed in its API reference; the example below uses the commonly documented question-mark style.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #3
- [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
- [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
- [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
- [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
- [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
import mariadb
def add_note(conn, body):
cur = conn.cursor()
try:
cur.execute(
"INSERT INTO notes (body) VALUES (?)",
(body,),
)
conn.commit()
return cur.lastrowid
except mariadb.Error:
conn.rollback()
raise
finally:
cur.close()
def get_note(conn, note_id):
cur = conn.cursor()
try:
cur.execute(
"SELECT id, body, created_at, updated_at "
"FROM notes WHERE id = ?",
(note_id,),
)
return cur.fetchone()
finally:
cur.close()
def update_note(conn, note_id, body):
cur = conn.cursor()
try:
cur.execute(
"UPDATE notes SET body = ? WHERE id = ?",
(body, note_id),
)
conn.commit()
return cur.rowcount
except mariadb.Error:
conn.rollback()
raise
finally:
cur.close()
def delete_note(conn, note_id):
cur = conn.cursor()
try:
cur.execute("DELETE FROM notes WHERE id = ?", (note_id,))
conn.commit()
return cur.rowcount
except mariadb.Error:
conn.rollback()
raise
finally:
cur.close()
The comma in (body,) makes a one-element tuple; omitting it passes a string instead. A successful INSERT, UPDATE, or DELETE is not durable until commit() runs. If any statement in a write operation fails, call rollback() before propagating the error. A read-only SELECT does not normally require a commit.
Fetch multiple rows without loading an unbounded result
def list_notes(conn, limit=50, offset=0):
cur = conn.cursor()
try:
cur.execute(
"SELECT id, body, created_at, updated_at "
"FROM notes "
"ORDER BY created_at DESC, id DESC "
"LIMIT ? OFFSET ?",
(limit, offset),
)
return cur.fetchall()
finally:
cur.close()
Validate pagination limits in application code before sending them to the database. For very large result sets, iterate over the cursor or page by an indexed key instead of calling fetchall() on an unbounded query. Treat database values as data when rendering them in HTML or other output; parameterized SQL prevents SQL injection, but output encoding is still required elsewhere.
Group related writes in one transaction
def move_note(conn, old_id, new_body):
cur = conn.cursor()
try:
cur.execute("UPDATE notes SET body = ? WHERE id = ?", (new_body, old_id))
if cur.rowcount != 1:
raise ValueError("note was not found")
cur.execute("INSERT INTO notes (body) VALUES (?)", ("audit: updated",))
conn.commit()
except (mariadb.Error, ValueError):
conn.rollback()
raise
finally:
cur.close()
Keep transactions short. Do not hold a transaction open while waiting for an HTTP request, user input, or a slow external service. Close cursors and connections on every path; a finally block or a carefully managed application lifecycle prevents leaked sessions.
Choose the VPS network boundary deliberately
MariaDB’s skip-networking setting disables TCP/IP listening, while bind-address controls which local addresses accept TCP connections. A firewall can still reject traffic even when MariaDB listens: the default port is 3306.
| Topology | Recommended approach | Required controls |
|---|---|---|
| Python and MariaDB on one VPS | Unix socket, or loopback TCP | Keep public TCP disabled where practical; use a local account and filesystem/service permissions. |
| Separate application host on a private network | Private address and TCP | Bind only to the private interface, grant the user to the expected source host, and restrict port 3306 in the VPS firewall. |
| Administrator connecting temporarily | SSH tunnel or private network | Authenticate with SSH, avoid public database exposure, and close the tunnel when finished. |
| Internet-facing database requirement | Only when unavoidable | Use narrow host grants, firewall allow-lists, TLS configured for the server and connector versions, monitoring, and a documented access review. |
Never grant a root account broad internet access. If a remote client cannot connect, check the listening address, skip-networking, the account’s host component, the VPS firewall, any cloud firewall, routing, and TLS settings in that order. Opening port 3306 alone does not make a valid or secure MariaDB connection.
Rank #4
- Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
- Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
- All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
- Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
- Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
Back up MariaDB and prove that recovery works
Use a logical dump when you need a portable SQL representation, and a physical backup when you need a faster, engine-aware copy suitable for larger InnoDB installations. MariaDB documents mariadb-dump for logical exports and mariadb-backup for physical backups.
Logical backup with mariadb-dump
mariadb-dump --single-transaction
--databases app_db
--user=backup_user --password
> app_db-$(date +%F).sql
--single-transaction is useful for transactional tables such as InnoDB because it can create a consistent snapshot without the same blocking behavior as a full table lock. Review options for routines, events, triggers, character sets, and any non-transactional tables in your schema. Protect the resulting SQL file because it contains application data and may expose sensitive values.
Physical backup with mariadb-backup
mariadb-backup --backup
--target-dir=/var/backups/mariadb/app_db-current
--user=backup_user --password
mariadb-backup --prepare
--target-dir=/var/backups/mariadb/app_db-current
A physical backup needs the restore procedure appropriate to the MariaDB version, datadir layout, permissions, and storage engine. Do not overwrite a live datadir casually; stop the service or follow the documented restoration sequence, preserve the failed instance for diagnosis, and verify ownership before starting MariaDB again.
Make the backup plan operational
- Schedule backups and retain enough generations for your application’s recovery-point objective.
- Copy completed dumps or prepared physical-backup directories away from the VPS. A disk snapshot on the same VPS is not protection from host loss.
- Encrypt transfers and backup storage, restrict access, and keep credentials out of shell history and logs.
- Monitor job exit status and resulting file size; a scheduled command that silently fails is not a backup.
- Restore into an isolated MariaDB instance on a recurring schedule, then run application checks against the restored data.
The right retention period, off-site storage location, and recovery-point and recovery-time objectives depend on the application; choose and document them rather than assuming a universal schedule.
Troubleshoot the failures you are most likely to see
Access denied for user
Check the username, password source, database name, and the account’s host part. 'app_user'@'localhost' is not the same account as 'app_user'@'127.0.0.1' or a remote address. Confirm grants from an administrative session and avoid solving the error by switching the application to root.
Best Value
Can't connect to local server
Confirm that the MariaDB service is running, inspect the socket path used by the distribution, and test whether the connector is attempting a Unix socket or TCP. Try an explicit socket path or loopback address after verifying the intended account host. Check service logs for startup and permission errors.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsRemote connection times out
Verify that MariaDB is bound to the required private address, that skip-networking is not disabling TCP, and that both the VPS firewall and any provider firewall allow port 3306 only from the expected source. A timeout usually indicates listening, routing, or filtering rather than a SQL privilege problem.
Writes disappear after a successful-looking request
Look for a missing commit(), an exception followed by connection reuse without rollback(), or a process exit before the transaction is committed. Log transaction errors without logging secrets, and make the write boundary explicit in code.
Placeholder or type errors after a connector upgrade
Read the installed Connector/Python major version’s parameter-style and prepared-protocol documentation. Do not mix placeholder conventions from another driver. Test inserts, updates, null values, dates, and binary data in a staging database before changing production.
Connection lifecycle and scaling choices
A single short-lived connection per request is simple and can be adequate for a small service, but connection creation has overhead and a burst of requests can exhaust MariaDB’s connection limit. Reuse connections through a carefully bounded pool only when the framework and connector version support it, and always return a connection after rolling back any unfinished transaction. Pool size must reflect MariaDB’s configured limits and the VPS’s CPU and memory; there is no universal number.
For a synchronous application, keep database work in bounded operations and set connection or read/write timeouts where supported. For asynchronous code, use a connector and integration designed for the event-loop model rather than blocking it with synchronous calls. Measure your own workload before changing indexes, isolation levels, or pool sizes; the available documentation does not establish a universal VPS performance benchmark.
Quick Recap
A production-readiness checklist
- MariaDB and Connector/Python versions are recorded and supported.
- The application uses a dedicated account, not root, with only required privileges.
- Secrets are outside source control and are rotated through an established process.
- All values use parameters; SQL text is not built by concatenating user input.
- Every write has an explicit commit and an exception rollback.
- Connections and cursors are closed, including error paths.
- Local traffic uses a Unix socket or loopback unless a justified private TCP path is required.
- Remote access, if necessary, is limited by bind address, host grants, firewall rules, and TLS.
- Logical or physical backups run on a schedule, leave the VPS, and are monitored.
- A recent backup has been restored successfully in an isolated environment.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




