Fix Question Marks Instead of Accents in MySQL

Database Errors Beginner 👁 5 views 📅 Jun 23, 2026

Accents show as ? in your DB because charset mismatch. Quick fix: set UTF-8 on connection and table. Takes 2 minutes.

Quick answer for advanced users

Run SET NAMES utf8mb4 right after connecting to your MySQL database, then check your table's charset is also utf8mb4. That's the fix 90% of the time.

Why this happens

You enter José into a form, but MySQL stores it as Jos?. Or you're reading data from a CSV that has Müller but the database shows M?ller. This is a charset problem. Your database thinks in one language (like latin1), but your data is in another (UTF-8). When MySQL tries to convert characters it doesn't understand, it replaces them with question marks.

Three things need to speak the same character language: your database table, your database connection, and your data source. If any one of them is set to latin1 (or a different charset), you get question marks.

I've seen this happen most often when someone moves a site from a cheap shared host to a new server. The old host used latin1, the new one defaults to UTF-8, and suddenly all the Spanish accents break. Or when you import a CSV file that was saved as ANSI but your table expects UTF-8.

Step 1: Check your table's charset

  1. Open phpMyAdmin or your MySQL client.
  2. Run this SQL command:
    SHOW TABLE STATUS LIKE 'your_table_name';
  3. Look at the Collation column. If it says something like latin1_swedish_ci or utf8_general_ci, that's your problem.
  4. After running the command, you'll see something like:
    Name: users, Engine: InnoDB, Collation: latin1_swedish_ci

If it's not utf8mb4_unicode_ci or utf8mb4_general_ci, you need to change it.

Step 2: Alter the table and columns

  1. Run these commands one at a time. They change the table's default charset and convert all text columns.
    ALTER TABLE your_table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  2. Wait for it to finish. For a big table (like 100k rows), this might take 10-20 seconds.
  3. After it finishes, you should see: Query OK, X rows affected.
  4. Now check your data. Run:
    SELECT * FROM your_table_name LIMIT 5;
    If you still see question marks, the damage is already done — those question marks are now stored as question marks. You'll need to re-import the original data.

Step 3: Fix the connection

Even if your table is UTF-8, your application might connect using latin1. This is the most common reason I see this issue. The fix depends on your programming language.

For PHP (mysqli)

Right after you connect, add this line:

$conn->set_charset('utf8mb4');

For PHP (PDO)

Include this in your connection string:

$pdo = new PDO('mysql:host=localhost;dbname=test;charset=utf8mb4', 'user', 'pass');

For Python (mysql-connector)

Add charset parameter:

conn = mysql.connector.connect(charset='utf8mb4')

For Ruby on Rails

In config/database.yml, add:

encoding: utf8mb4

If the main fix doesn't work

Sometimes the data is already corrupted. The question marks are literally stored as question marks (character code 63). You can't undo that — you need to re-import the original data.

But here's what might still be wrong:

  • Your HTML page charset — Make sure your HTML has this meta tag:
    <meta charset="UTF-8">
  • Your CSV file encoding — If you're importing data from a CSV, open it in Notepad++, go to Encoding menu, and make sure it says Encode in UTF-8-BOM. Save it, then re-import.
  • Your MySQL client — If you're running SQL commands from a terminal on Windows, the terminal itself might not support UTF-8. Use a proper client like MySQL Workbench or DBeaver instead.

How to prevent this

Do these three things on every new project:

  1. Set your MySQL default charset to utf8mb4 at the server level. Edit my.cnf and add:
    [mysqld]
    character-set-server = utf8mb4
    collation-server = utf8mb4_unicode_ci
  2. When you create a new table, always specify charset:
    CREATE TABLE users (
      id INT AUTO_INCREMENT PRIMARY KEY,
      name VARCHAR(100)
    ) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  3. In your application code, set the connection charset immediately after connecting. Do it every time. Don't skip it.
  4. If you're using PHP, also set the default charset in php.ini:
    default_charset = "UTF-8"

Once you do these, you'll never see question marks again. I promise. I've fixed this issue on at least 30 different sites, and this is the only way that works long-term.

Was this solution helpful?