iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
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 reliable production path is straightforward: install and secure MySQL on the VPS (or use a managed MySQL service), create a database and least-privilege application user, add the mysql2 adapter, provide Rails with a protected production connection URL, run the schema tasks against the intended database, and verify the app from the same host where it runs.
The details that usually cause outages are not the Rails model layer. They are mismatched MySQL grants, credentials committed to source control, a connection pool that does not fit the application server, remote-firewall or TLS settings, and migrations run against the wrong environment. The procedure below addresses each of those points.
Choose where MySQL will run
You can install MySQL on the same VPS as Rails or connect Rails to a managed MySQL service. Both work with Rails through the mysql2 adapter; the operational trade-off is different.
| Decision | MySQL on the VPS | Managed MySQL |
|---|---|---|
| Administration | You install, secure, upgrade, monitor, and recover the database service. | The provider handles much of the database service administration; you still manage users, schema, application settings, and access policy. |
| Network path | Rails can use a local Unix socket or loopback TCP, avoiding an external network hop. | Rails connects over a network, so private routing, firewall rules, DNS, and usually TLS must be correct. |
| Backups and recovery | You must configure, test, and retain backups yourself. | Backup features depend on the service and plan; verify retention and restoration procedures rather than assuming they exist. |
| Patching | You schedule MySQL and operating-system updates and restart services when required. | The provider supplies the maintenance process, but you must account for maintenance windows and compatibility. |
| Cost and capacity | Database CPU, memory, disk, and I/O compete with Rails on the VPS. | Database resources are billed separately, but capacity can be isolated from the application host. |
For a small single-server deployment, local MySQL is often the simplest topology. A managed service is attractive when you do not want database patching and backup administration, or when the database must survive replacement of the application VPS. In either design, keep the connection details in deployment secrets and make the network boundary explicit.
#1 Best Overall
- Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
- With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
- Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
- Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
- Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.
Prepare the VPS
Use a supported server image
Start with an Ubuntu LTS image or another Linux distribution supported by your deployment process. The host needs Ruby, Bundler, the Rails application’s native dependencies, and either a local MySQL server or network access to the managed instance. Install and test the Ruby version and Bundler version required by the application’s lockfile before attempting a production migration.
Install the MySQL server package
On Ubuntu, install the distribution’s MySQL server package, then apply the vendor’s security setup. A typical sequence is:
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →sudo apt update
sudo apt install mysql-server
sudo mysql_secure_installation
The security script’s questions vary with the distribution and MySQL packaging. Review each change, remove anonymous accounts and test databases when offered, and choose an administrative authentication method that fits your operational access plan. Do not use the MySQL root account from Rails.
Check the service before configuring Rails
Ubuntu manages MySQL with systemd. Confirm that the service is running and enabled at boot:
sudo systemctl status mysql
sudo systemctl is-enabled mysql
sudo systemctl is-active mysql
The Ubuntu service unit is commonly exposed as /lib/systemd/system/mysql.service. Treat that unit as package-owned; put local changes in a systemd drop-in rather than editing the vendor file. When a systemd override changes, reload systemd and restart MySQL:
sudo systemctl daemon-reload
sudo systemctl restart mysql
sudo systemctl status mysql
If you are using a managed service instead, skip local installation and record the provider’s hostname, port, database name, TLS requirements, and allowed source addresses. Test reachability from the VPS before changing Rails.
Recommended Free Tools
Rank #2
- Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
- Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
- Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
- Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
- Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
Create a production database and application user
Log in with an administrative MySQL account on the database host. The following example uses a database named myapp_production and an application account named myapp; choose names that match your deployment.
sudo mysql
Create the database with Unicode support, create a dedicated account, and grant only the privileges your Rails application needs:
CREATE DATABASE myapp_production
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
CREATE USER 'myapp'@'localhost'
IDENTIFIED BY 'change-this-to-a-long-random-secret';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, INDEX, REFERENCES,
CREATE TEMPORARY TABLES, LOCK TABLES
ON myapp_production.* TO 'myapp'@'localhost';
FLUSH PRIVILEGES;
EXIT;
The password in the example is illustrative; replace it with a generated secret before use and store it in your secret manager. Migration workflows may require schema-changing privileges such as CREATE, ALTER, and INDEX. If you separate migration credentials from runtime credentials, the runtime account can receive a narrower set of privileges after deployment. Never grant global privileges merely to make an error disappear.
Match the MySQL account host to the connection path
MySQL accounts include both a username and a host pattern. An account created as 'myapp'@'localhost' is intended for a local connection. A remote managed database normally requires an account whose host pattern and network policy match the application source address. Avoid an unrestricted host pattern when a private address range or a specific application host can be used. If you change from a Unix socket to TCP, verify that the account definition and server grants still match the path you selected.
Add the Rails MySQL adapter
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'
Run Bundler in the same Ruby environment used by production and commit the resulting lockfile:
Rank #3
- 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
- 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
- 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
- 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
- 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
bundle install
bundle check
On the VPS, deploy the locked bundle and ensure the native build prerequisites required by the gem are installed by your distribution. A successful local bundle does not prove that the production host has the compiler, MySQL client headers, or compatible libraries needed to build mysql2.
Configure the production connection
Use a protected DATABASE_URL
Rails reads connection information from config/database.yml or from ENV['DATABASE_URL']. Keeping the production password outside source control is usually the cleanest deployment workflow. A minimal production section is:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
production:
url: <%= ENV['DATABASE_URL'] %>
Set the variable in the process environment or your deployment secret store. A MySQL URL identifies the adapter, credentials, host, optional nonstandard port, and database:
mysql2://myapp:encoded-password@127.0.0.1:3306/myapp_production
For a local Unix-socket connection, configure the socket explicitly when needed instead of relying on an implicit host interpretation. For a remote service, use its private hostname or address, the provider’s port, and the TLS options it requires. Do not expose the URL in shell history, logs, issue trackers, or a rendered error page.
Escape credentials correctly
Passwords and usernames are URL components. Characters such as @, :, /, #, and spaces must be percent-encoded before they are placed in DATABASE_URL. An unescaped @, for example, can be interpreted as the boundary between credentials and hostname. Generate the URL in your secret-management workflow, then validate it with a non-destructive connection check rather than printing the secret.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Use explicit YAML when your deployment system requires it
Some teams inject separate variables and keep the structure visible in config/database.yml:
Rank #4
- 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
- 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
- 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
- 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
- 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
production:
adapter: mysql2
encoding: utf8mb4
database: myapp_production
username: myapp
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) %>
Do not commit a real password in this file. The utf8mb4 encoding in Rails’ MySQL example is the appropriate starting point for modern Unicode data. If your server uses a non-default collation or SQL mode, document and test that choice before production traffic reaches it.
Account for advisory locks
Rails enables MySQL advisory locks by default for concurrent-safe migrations. Leave that behavior enabled unless your deployment design requires otherwise and you have verified the consequences. If you must disable it, set the Rails database configuration explicitly and ensure your migration process cannot run conflicting jobs concurrently.
Size the connection pool for the application server
The pool is the number of database connections Rails can check out for a process. Rails’ MySQL example includes pool: 5, but that number is not a universal production setting. Set the pool with the number of Puma (or other application-server) threads, the number of web processes, background-job processes, and the MySQL server’s connection limit in mind.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute- A pool smaller than the maximum concurrent database work makes threads wait for a connection and can look like application slowness.
- A pool larger than the actual workload wastes database connections.
- Multiplying the pool by every web and worker process can exhaust MySQL even when each process appears reasonable in isolation.
- Change one dimension at a time and observe checkout waits, request latency, and MySQL connection usage.
Choose the value from your application’s concurrency and the database capacity you have provisioned; there is no single Rails default that fits every VPS.
Run the production schema tasks safely
Load the same secret environment that the Rails process will use, set RAILS_ENV=production, and verify the target before making changes. On a new database, the deployment task commonly follows this pattern:
RAILS_ENV=production bin/rails db:prepare
db:prepare creates the database when appropriate and runs migrations or loads the schema according to the Rails version. Some deployment processes call the operations separately:
Best Value
- 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
- 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
- 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
- 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
- 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
RAILS_ENV=production bin/rails db:create
RAILS_ENV=production bin/rails db:migrate
For a deliberately fresh environment, a schema load may be faster than replaying every historical migration:
RAILS_ENV=production bin/rails db:schema:load
Use the task supported by your Rails version and release process. Before any destructive task, inspect the resolved host and database name through a safe administrative check. Never run a production command with an omitted environment variable that silently falls back to development or a local database.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Start Rails and test from the VPS
Run the application under supervision
Start Puma or your selected Rails application server through the same supervisor used for the rest of the deployment. Keep the Rails process and MySQL under service supervision so they restart predictably and their logs have a known location. Rails’ current deployment guidance includes Kamal and an Ubuntu LTS server path; a traditional systemd setup is also valid when it matches your team’s operational skills.
Exercise a database-backed path
After the process starts, test a health endpoint that performs a real database query, not only a static response. Run the check from the VPS or an equivalent application host so DNS, routing, firewall, socket, and credentials are tested along the same path as production traffic. Confirm that a normal request can read and write the records expected by the application, then inspect the Rails and MySQL logs for warnings.
Choose Unix socket or TCP deliberately
| Connection type | Best fit | Advantages | Things to verify |
|---|---|---|---|
| Unix socket | Rails and MySQL on the same VPS. | No network firewall exposure and no TCP hop; access is local to the host. | Socket path, filesystem permissions, and the MySQL account host matching the local connection. |
| Loopback TCP | Local services that need a TCP endpoint or a consistent URL format. | Explicit host and port; easier to compare with a remote configuration. | MySQL listening address, local firewall rules, and grants for the connection host. |
| Private remote TCP | Managed MySQL or a database on another private host. | Separates database resources from the application VPS. | Private routing, security-group or firewall rules, DNS, TLS, certificate validation, and provider maintenance windows. |
Do not switch paths while troubleshooting several variables at once. First prove a connection with the chosen host, port or socket, account, and database; then change one setting and retest.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteQuick Recap
Troubleshoot the common failure modes
| Symptom | Likely cause | Checks and fix |
|---|---|---|
Can't connect to MySQL server |
MySQL is stopped, listening on another address, blocked by a firewall, or the hostname resolves incorrectly. | Check systemctl status mysql, confirm the configured host and port, test DNS and reachability from the VPS, and inspect firewall rules. Restart MySQL after a validated configuration change. |
Access denied for user |
The password is wrong, the account host does not match, or the URL was parsed incorrectly. | Inspect the account definition as an administrator, compare the exact username and host, percent-encode special password characters, and rotate the secret if it may have leaked. |
| Rails connects locally but not on the VPS | Development uses a different database, socket, environment variable, or MySQL account. | Print non-secret configuration facts in a controlled shell, confirm RAILS_ENV=production, and test the same URL from the VPS with a MySQL client. |
| Migration hangs waiting for a connection | The pool is too small for concurrent work, or another process is holding connections. | Inspect application-server process and thread counts, MySQL connection usage, and pool checkout waits. Reduce unnecessary concurrency or raise the pool only within the database’s capacity. |
| Unknown database | The database was not created on the host named by the production URL. | Connect administratively to that exact host and list databases; create the production database there or correct the secret. |
| Character or collation errors | The server, database, and Rails connection use incompatible character settings. | Confirm the database was created with utf8mb4, review the connection encoding, and test the affected migration or data with representative Unicode text. |
| TLS or certificate errors on a managed service | The provider requires encrypted transport or the client does not trust the certificate. | Follow the provider’s required SSL mode and certificate settings, use the private endpoint when available, and verify the certificate hostname. |
| Service changes disappear after an update | A package-owned systemd unit was edited directly. | Move local settings into a systemd drop-in, run systemctl daemon-reload, restart MySQL, and keep the drop-in in your deployment documentation. |
Production security and operations checklist
- Use a dedicated MySQL account for Rails; never place MySQL
rootcredentials in the application environment. - Keep
DATABASE_URLor individual database variables in a protected secret store with restricted process and operator access. - Grant the application only the database-level privileges required by runtime and migration workflows.
- Restrict remote MySQL access to private networks or known application sources; do not open the database port to the entire internet.
- Require TLS for remote connections when the managed service or network design calls for it, and validate certificates.
- Back up the database and perform a restoration test on a schedule appropriate to the data’s importance.
- Apply operating-system and MySQL security updates during a planned maintenance process, then verify the service state.
- Monitor failed connections, connection saturation, disk space, replication or provider health indicators when applicable, and migration failures.
- Keep migration execution serialized so two deploys cannot change the schema concurrently.
- Document the database host, socket or port, secret source, backup location, and rollback procedure for the on-call operator.
A repeatable deployment sequence
- Provision an Ubuntu LTS VPS or select a managed MySQL endpoint, then install Ruby, Bundler, Rails dependencies, and the locked application bundle.
- Install and secure MySQL when it is local, or record the managed service’s private endpoint and TLS requirements.
- Confirm that MySQL is enabled and active, and place any local systemd customization in a drop-in.
- Create the
utf8mb4production database and a dedicated application user with least-privilege grants. - Generate and store the production connection secret; verify URL escaping and do not commit it.
- Deploy
mysql2and the lockfile, then configureconfig/database.ymlto readDATABASE_URLor protected individual variables. - Set a connection pool that reflects Puma or worker concurrency and the MySQL connection capacity.
- Run the appropriate production database task and verify that it reaches the intended host and database.
- Start Rails under your supervisor, exercise a database-backed health check, and inspect logs.
- Record the backup, patching, monitoring, and recovery procedures before accepting production traffic.
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.

