Category: MySQL

Fixing MySQL DEFINER Errors on AWS RDS (Trigger Import)

When importing a MySQL dump into Amazon RDS, you might hit an error like:

In the dump you’ll often see a trigger, view, or routine created with a DEFINER that doesn’t match your current user, for example:

On RDS you typically don’t have SUPER (legacy) or SET_USER_ID (modern) privileges, so MySQL refuses to create the object with someone else’s DEFINER. TL;DR (the quick, safe fix) Strip the DEFINER=… clauses from the dump so MySQL defaults to the importing user.

Notes The versioned comments like /*!50017 … */ are fine to keep. Removing only the DEFINER=… text is enough. On macOS, use sed -E -i ” ‘s/…/…/g’ file.sql (empty string after -i). Alternative: keep an explicit definer (without elevated privileges) If you prefer to keep an explicit definer, rewrite to CURRENT_USER:

CURRENT_USER is allowed in object definers and avoids the privilege requirement. Why this happens (in one

Read More »

Fixing MySQL 8 Import Error: NO_AUTO_CREATE_USER in sql_mode

When importing a MySQL 5.7 (or older) dump into MySQL 8.0, the process can fail with:

This article explains why it happens and shows safe, repeatable fixes you can apply immediately. TL;DR (One‑liner fix) Strip the deprecated token from the dump as you import it:

Replace DB_HOST, DB_USER, and DB_NAME to match your environment. Why this error appears Older dumps often contain version‑gated statements like:

NO_AUTO_CREATE_USER was removed in MySQL 8.0. Attempting to include it in sql_mode causes MySQL to abort the import with ERROR 1231. The behavior controlled by NO_AUTO_CREATE_USER no longer exists in 8.0 (user creation and grants were redesigned), so it’s safe to remove the token. Solution A — Clean the dump, then import (recommended) Locate the offending token

Remove it everywhere (preserve the rest of the sql_mode list and clean up commas):

Import the cleaned dump

Why this is preferred

Read More »

Enabling TLS for CodeIgniter (MySQLi) on Amazon RDS

Transport Layer Security (TLS) encrypts traffic between your app and database, protecting credentials and data in transit. This guide shows how to enable and verify TLS for a CodeIgniter 4 app using the MySQLi driver against Amazon RDS/Aurora MySQL—whether you have root on the host or not. It also covers enforcing TLS at the database and common pitfalls. What you’ll do Download the Amazon RDS CA bundle Point CodeIgniter’s MySQLi connection at that CA Verify the connection is encrypted (with either MySQL or MariaDB clients) Optionally require TLS at the DB parameter group level 1) Get the Amazon RDS CA bundle Use either the global bundle (works for all commercial regions) or a region-specific bundle (e.g., us-east-1). Global (covers any commercial region): https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem Regional example (N. Virginia): https://truststore.pki.rds.amazonaws.com/us-east-1/us-east-1-bundle.pem With root (system-wide location)

Without root (per-site location, safe for Plesk)

Sanity checks:

Plesk note: if PHP has open_basedir

Read More »

How to Set Up a Secure SSH Tunnel for MySQL Access with a Restricted User

Introduction In many scenarios, database servers are not exposed directly to the internet for security reasons. However, developers and applications still need to connect to them securely. One of the best solutions is to create an SSH tunnel that forwards local connections to the remote MySQL server. In this guide, we will: Create a restricted SSH user who can only tunnel and not log in interactively. Use /sbin/nologin to prevent shell access. Set up port forwarding for secure MySQL access. Test and verify the tunnel. Step 1: Create the SSH User On the SSH gateway server, create a dedicated user:

Set a strong password when prompted. Step 2: Restrict the User to SSH Tunneling Only Set the User’s Shell to /sbin/nologin To prevent interactive logins, change the user’s shell:

Restrict the User in SSH Configuration Edit the SSH config file:

Add the following at the bottom:

Read More »

Add Extra MySQL Root User

To add an extra “root” capable MySQL user start by logging in to the server on SSH and connect to MySQL CLI using an existing “root” level account. Next add the new user account:

Next grant permissions:

Now flush the privileges cache:

You might want to double check the results with:

   

Read More »

Categories

Get a free consultation from Reliable Penguin

Submit the form—or for immediate service call 866-649-7984.