Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →To connect Rails to MySQL on a VPS, install and secure MySQL (or obtain credentials for a managed MySQL service), create a database and least-privilege application user, add the mysql2 gem, supply production credentials through DATABASE_URL or protected deployment secrets, run the production migrations, and test from the VPS itself. Keep MySQL supervised by systemd and size Rails’ connection pool to your application-server concurrency.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
The most common reason a connection works locally but fails in production is not Rails code: the server is reaching the wrong host or socket, the MySQL account is not permitted from that host, a firewall blocks TCP, a password is malformed in the URL, or the production process never received its secrets.
As an Amazon Associate I earn from qualifying purchases.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Choose where MySQL will run
You can run MySQL on the same VPS as Rails or use a managed MySQL service reachable over a private network or secured public connection. Both work with Rails’ mysql2 adapter; the operational responsibilities differ.
| Decision | MySQL on the Rails VPS | Managed MySQL |
|---|---|---|
| Administration | You install, secure, patch and tune the daemon. | The provider handles the database service; you manage credentials, schema and application settings. |
| Network path | A Unix socket or loopback TCP connection can avoid an external network hop. | The app connects over a private or public network endpoint, usually with firewall and possibly TLS requirements. |
| Backups and recovery | You must schedule, protect and test backups. | Backup features depend on the provider and plan; verify retention and restore procedures. |
| Cost and capacity | Database CPU, memory and storage consume the VPS resources. | Database capacity is billed separately but can be scaled independently. |
| Failure isolation | A VPS outage affects both app and database. | The services can fail independently, but the app depends on network reachability. |
For a small game API or dashboard, local MySQL is often the simplest starting point. A managed service is preferable when you do not want database patching and backup administration, or when the database needs capacity and availability independent of the application host.
#1 Best Overall
- BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
- EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
- COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
- LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
- WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
Prepare the VPS
Required components
- An Ubuntu LTS image or another Linux distribution supported by your deployment process.
- The Ruby version required by the application, Bundler, Rails dependencies and a working application checkout.
- MySQL Server installed locally, or a managed MySQL endpoint and its network policy.
- A deployment mechanism that can provide secrets without committing them to source control.
- Firewall rules that allow only the traffic your design needs. A local-only database normally does not need an internet-facing MySQL port.
Run administrative commands as a privileged account, but run Rails and its database tasks as the application user. Do not use the MySQL root account from Rails.
Install and secure MySQL on Ubuntu
Install the distribution package
On an Ubuntu VPS, install the distribution’s MySQL server package and check the service immediately:
sudo apt update
sudo apt install mysql-server
sudo systemctl enable --now mysql
sudo systemctl status mysql
The service is managed by systemd as mysql.service. A status of active (running) confirms that the daemon started; it does not yet prove that your Rails credentials or grants are correct.
Apply the vendor security setup
Run the security configuration supplied by your distribution and MySQL release, commonly exposed as:
sudo mysql_secure_installation
Review each prompt rather than blindly accepting defaults. Remove anonymous accounts, prevent remote administrative access unless you have a documented reason to keep it, remove the test database, and choose an authentication policy compatible with your administration tools. Keep the application account separate from administrative accounts.
Restart after configuration changes
When you change MySQL configuration, restart the service and inspect its logs if it does not return to active (running):
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →sudo systemctl restart mysql
sudo systemctl status mysql
sudo journalctl -u mysql --since "15 minutes ago"
If you create or change a systemd service override, reload systemd before restarting MySQL:
sudo systemctl daemon-reload
sudo systemctl restart mysql
Create a production database and application account
Log in through the local administrative method supplied by your installation, then create a database with the character set Rails’ MySQL example uses, utf8mb4. Choose names that identify the environment and application.
Rank #2
- WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
- AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
- PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
- ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
- COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
sudo mysql
CREATE DATABASE game_api_production
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
CREATE USER 'game_api'@'localhost'
IDENTIFIED BY 'replace-with-a-long-random-secret';
GRANT ALL PRIVILEGES ON game_api_production.*
TO 'game_api'@'localhost';
FLUSH PRIVILEGES;
EXIT;
The 'user'@'host' portion matters. An account created for localhost is not automatically the same account as one created for a remote hostname or IP address. If Rails will connect from another machine, create a narrowly scoped host entry that matches your private network design instead of opening access to every host.
Grant only the privileges the application needs. A typical Rails deployment needs to read and write application tables; schema changes should be performed by a controlled deployment identity or a deliberately authorized application account. Never publish the password in a repository, shell history, ticket, image or log.
Free tools Windows power users keep installed
One-click scans. No signup required.
Verify the account before involving Rails:
mysql -u game_api -p -h 127.0.0.1 game_api_production -e 'SELECT 1;'
Use localhost instead of 127.0.0.1 when you specifically want the client’s local socket behavior. Testing the same host and transport that Rails will use prevents a misleading “works in the shell” result.
Add the MySQL adapter to Rails
Rails supports MySQL and MariaDB through the mysql2 adapter. Add the gem to the application’s Gemfile if it is not already present:
gem "mysql2"
Resolve and install the bundle in the deployment environment:
bundle install
If native compilation fails, install the MySQL client development package and the build tools required by your Linux distribution, then run Bundler again. Keep the Ruby, Rails, mysql2 and MySQL client versions compatible with the application’s lockfile and supported platform.
Configure production credentials
Prefer an injected DATABASE_URL
Rails can read connection information from config/database.yml or ENV['DATABASE_URL']. The production configuration should make the environment variable usage explicit so the password stays out of source control:
production:
url: <%= ENV['DATABASE_URL'] %>
Provide the complete URL through your process supervisor or deployment secret store. A MySQL URL identifies the adapter, username, password, host, optional nonstandard port and database name. A generic shape is:
Rank #3
- Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
- Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
- Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
- ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
- Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
mysql2://USER:PASSWORD@HOST:PORT/DATABASE
Do not copy that example literally. Replace every component with your deployment values, omit the port only when the service uses its standard port, and URL-escape reserved characters in usernames and passwords. A password containing characters such as @, :, /, ? or # can otherwise be parsed as part of the URL rather than as a credential.
For a local Unix socket, configure the socket explicitly in database.yml or use the connection format supported by your adapter version. For a remote database, use its private address where possible and enable the TLS options required by that service.
Recommended Free Tools
Use database.yml for non-secret structure
You can keep adapter and pool settings in config/database.yml while injecting the secret values separately:
production:
adapter: mysql2
encoding: utf8mb4
database: <%= ENV.fetch("MYSQL_DATABASE") %>
username: <%= ENV.fetch("MYSQL_USERNAME") %>
password: <%= ENV.fetch("MYSQL_PASSWORD") %>
host: <%= ENV.fetch("MYSQL_HOST", "127.0.0.1") %>
port: <%= ENV.fetch("MYSQL_PORT", "3306") %>
pool: <%= ENV.fetch("RAILS_MAX_THREADS", 5) %>
Use either this structured approach or a production DATABASE_URL as your source of truth. If both are present, confirm which values your Rails version and deployment tooling merge or override; ambiguity makes incidents harder to diagnose.
Set the connection pool deliberately
The Rails MySQL example includes pool: 5, but that is an example, not a universal capacity rule. Set the pool to match the number of concurrent threads used by Puma or another application server, while leaving headroom for console sessions, jobs and migrations. A pool that is too small makes requests wait for a connection; a pool that is too large can exhaust MySQL’s permitted connections, especially when several application processes run on the same VPS.
Change the pool only after counting every Rails process and its maximum threads. Coordinate the resulting total with the MySQL server’s configured connection limit and the capacity of the VPS.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Advisory locks and migrations
Rails enables MySQL advisory locks by default for concurrent-safe migrations. Leave that behavior enabled unless your deployment architecture requires a documented alternative. If you disable it, ensure your release process prevents two migration runners from changing the schema at the same time.
Run the production schema tasks safely
Load the production secret into the same environment used by the Rails process, set RAILS_ENV=production, and run the task appropriate to your application’s history. A new database may need creation and schema loading; an existing database normally needs migrations.
Rank #4
- Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
- Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
- 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
- Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
- USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
RAILS_ENV=production bin/rails db:create
RAILS_ENV=production bin/rails db:migrate
Use db:schema:load only when that is appropriate for the project’s deployment policy and schema format. Before running a destructive task, print or inspect the effective host and database name through a safe, non-secret check. Confirm that it is the intended production database, not a local development instance or another tenant.
After the migration, verify that Rails can query the database through its own environment:
RAILS_ENV=production bin/rails runner 'puts ActiveRecord::Base.connection.select_value("SELECT 1")'
Do not paste passwords into command lines that may be recorded by process inspection or shell history. Supply secrets through the supervisor, a protected environment file with restrictive permissions, or your deployment platform’s secret mechanism.
Start Rails under supervision and test it from the VPS
Run Puma or your selected application server under the same service manager used for the rest of the deployment. The service must receive the production environment, application directory, Ruby path and bundle path; a shell that works interactively does not prove the system service has those values.
After starting Rails, exercise a health endpoint and at least one database-backed request from the VPS:
curl -f http://127.0.0.1:3000/health
curl -f http://127.0.0.1:3000/api/health
Use the route that actually exists in your application. Check the Rails service logs and MySQL logs at the same time. A successful process start followed by a database error on the first request usually indicates a missing secret, incorrect host, failed grant or TLS mismatch rather than a failed Ruby boot.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Choose socket or TCP intentionally
Unix socket for a local database
A Unix socket keeps traffic on the VPS and avoids exposing a MySQL TCP port. It is local to the host and depends on the socket path configured by the MySQL package. If Rails and MySQL use different socket paths, the client may report that the file does not exist even though the daemon is running. Find the active socket in MySQL’s configuration or with the server’s status tools, then set the same path in the Rails connection.
TCP for local or remote connections
TCP is explicit and works for a managed service or a database on another host. Use 127.0.0.1 rather than localhost when you need to force loopback TCP on a local installation. For a remote endpoint, confirm DNS resolution, route and firewall rules from the Rails VPS, and restrict MySQL grants to the application’s source address. Never open the database port broadly just to make an initial test pass.
Best Value
- Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
- Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
- Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
- Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
- Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
TLS for remote MySQL
Use the managed service’s required certificate and TLS settings when the database is remote. A connection that reaches the server but fails during negotiation is different from a firewall timeout; read the exact Rails or MySQL client error and compare the adapter options with the provider’s required certificate, mode and hostname verification.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesDiagnose “works locally, fails on the VPS”
| Symptom | Likely cause | What to check |
|---|---|---|
| Connection refused or timeout | MySQL is stopped, the port is blocked, or the endpoint is wrong. | Check systemctl status mysql, the configured host and port, VPS egress rules, remote firewall rules and whether the service listens on the expected interface. |
| “Can’t connect through socket” | Rails is using a missing or different Unix socket. | Compare the socket path in MySQL configuration with the Rails adapter settings, or force the intended TCP address. |
| “Access denied for user” | The password, host-specific grant or authentication method is wrong. | Test with the same username, host and transport using the MySQL client; inspect the account’s host entry and reset the secret if necessary. |
| Unknown database | The database was not created, or the URL names another environment. | Log in administratively, list databases, and compare the exact database name in the deployment secret. |
| Rails starts but first request fails | The service did not receive the production environment or bundle. | Inspect the supervisor’s environment, working directory, Ruby path and service logs; do not rely on an interactive shell test. |
| TLS or certificate error | A remote service requires encrypted transport or a trusted CA. | Install the required CA material and set the adapter’s TLS options exactly as the database service documents. |
| Requests wait or MySQL rejects new sessions | The Rails pool is too small or aggregate pools exceed MySQL capacity. | Count processes and threads, inspect active sessions, then reduce or increase the pool in coordination with the server limit. |
Capture the complete exception class and the first useful line of its cause chain. “Database unavailable” is not enough to distinguish DNS, firewall, authentication, socket and schema problems.
Operate the connection after launch
Keep both services supervised
Enable MySQL at boot and use systemd or your deployment tooling to restart Rails after a host reboot. After changing MySQL configuration, perform the systemd daemon reload when an override changed, restart MySQL, and verify status before sending traffic back to Rails.
Back up and test restores
If MySQL is on the VPS, schedule backups outside the database volume and protect them separately from the host. A backup that has never been restored is an assumption, not a recovery plan. For managed MySQL, confirm the provider’s retention, point-in-time recovery, export format and restore destination before relying on it.
Patch deliberately
Apply Ubuntu, MySQL, Ruby and gem security updates through a repeatable process. Read release notes for authentication or client-library changes, test migrations against a copy of production data, and keep a rollback plan for the Rails release and database schema.
Monitor useful signals
- Rails error rate and latency for database-backed endpoints.
- MySQL availability, failed connections, active sessions and storage growth.
- VPS CPU, memory, disk space and I/O saturation.
- Backup completion and restore-test results.
- Certificate expiration when remote TLS is used.
Deployment models: systemd, containers and Kamal
A traditional VPS deployment can run Puma and MySQL directly under systemd. This keeps the process model visible and makes host-level logs and resource limits straightforward. Containers separate application packaging from the host, but you still need persistent MySQL storage, networking, secret injection and a backup strategy.
Rails’ current deployment guidance includes Kamal and an Ubuntu LTS server path. If you use Kamal or another container deployment tool, apply the same database principles: keep DATABASE_URL out of the image, provide it to the running release, verify the network name and port from inside the application container, and run migrations exactly once per release. Do not assume a container’s localhost is the VPS or the MySQL container; it is the container itself.
Quick Recap
Production connection checklist
- Ruby, Bundler, Rails dependencies and
mysql2are installed from the locked bundle. - MySQL is running, enabled and secured, or the managed endpoint is reachable from the VPS.
- The production database exists with
utf8mb4and the intended name. - The Rails account is dedicated, uses a strong secret and has only required grants.
DATABASE_URLor equivalent variables are injected into the Rails service, not committed to Git.- The URL’s special characters are escaped and its host, port and database are correct.
- The connection pool matches Puma or other application-server concurrency.
- Production migrations were run against the verified target database.
- A health check and a real database-backed endpoint succeed from the VPS.
- Logs, backups, restore tests and restart procedures are in place.
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.




