Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emoji's in mysql turns to question marks

Tags:

mysql

emoji

I am trying to insert emoji's into mysql but it turns to question marks, I have changed mysql connection server collation, database collation , table collation and column collation. I used these to change the items

# For each database:
ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
# For each table:
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# For each column:
ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

I have done all these but emoji's in mysql still show question marks. Please what should I do to make mysql show the emojis. Thanks in advance

like image 889
George Avatar asked Oct 28 '15 08:10

George


People also ask

Why are my emojis coming out as question marks?

Even when Google, Apple, and Microsoft draw their emojis in different styles, the Unicode behind them remains the same. Your emojis show up as a question mark in a box on when your iPhone doesn't recognize the Unicode for it.

How do I save emojis to my database?

Use urlEncoder to encode your String having emoticons. Store it in DB without altering the MysqlDB. You can store it in solr core(decoded form)if you want or you can store encoded form.

What is question mark in mysql query?

The question mark represents a parameter that will later be replaced. Using parameterized queries is more secure than embedding the parameters right into the query. SQL Server calls this parameterize queries, and Oracle calls it bind variables.


1 Answers

Little late to answer the question. But I hope it will be useful for others...

Above configuration makes the database tables to store utf8 encoded data. But, the database connection(JDBC) should be able to transfer the utf8 encoded data to client. For that the JDBC connection parameter charset should be set to utf8mb4.

like image 57
Vamshi Avatar answered Oct 04 '22 14:10

Vamshi