3

So I finally got native emojis working on my site (posts/comments/messages etc) 🙂 and thought I should share it here in case anyone's also struggling (and even for me to look at it later). It's in continuation to this thread.

Assumptions and stuff:

  1. You must be logged in as root.

  2. You'll be doing all your tasks in MySQL

  3. Your database character set is anything another than utf8mb4. This could be Latin 1 or utf8 and the Collation is utf8generalci or latin1swedishci. In my case, my throat database was Latin1. Use the following query to find that out for all the databases in your server:

    SELECT SCHEMA_NAME 'database', default_character_set_name 'charset', DEFAULT_COLLATION_NAME 'collation' FROM information_schema.SCHEMATA;

    Sample result (pic)

  4. Back up your database before running any of the following commands.

That said, all you need to do is run the following commands one after the other (replace throat with the name of your Phuks database).

Notice that we are altering the whole database PLUS the exsiting data in the sub_post_comment, sub_post, sub, and message tables.

  • ALTER DATABASE throat CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

    Sample RESULT: Query OK, 1 row affected (0.00 sec)

  • SET FOREIGN_KEY_CHECKS = 0;

    Sample RESULT: Query OK, 0 rows affected (0.00 sec)

  • ALTER TABLE sub_post_comment CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

    Sample RESULT: Query OK, 343 rows affected (0.10 sec)

    Sample RESULT: Records: 343 Duplicates: 0 Warnings: 0

  • ALTER TABLE sub_post CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

    Sample RESULT: Query OK, 244 rows affected (0.08 sec) Sample RESULT: Records: 244 Duplicates: 0 Warnings: 0

  • ALTER TABLE sub CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

    Sample RESULT: Query OK, 24 rows affected (0.03 sec)

    Sample RESULT: Records: 24 Duplicates: 0 Warnings: 0

  • ALTER TABLE message CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

    Sample RESULT: Query OK, 314 rows affected (0.09 sec) Sample RESULT: Records: 314 Duplicates: 0 Warnings: 0

  • SET FOREIGN_KEY_CHECKS = 1;

    Sample RESULT: Query OK, 0 rows affected (0.00 sec)

So I finally got native emojis working on my site (posts/comments/messages etc) 🙂 and thought I should share it here in case anyone's also struggling (and even for me to look at it later). It's in continuation to [this thread](https://phuks.co/s/phuksdev/66541). **Assumptions and stuff:** 1. You must be logged in as root. 2. You'll be doing all your tasks in MySQL 3. Your database character set is anything another than **utf8mb4**. This could be **Latin 1** or **utf8** and the Collation is **utf8_general_ci** or **latin1_swedish_ci**. In my case, my **throat** database was **Latin1**. Use the following query to find that out for all the databases in your server: `SELECT SCHEMA_NAME 'database', default_character_set_name 'charset', DEFAULT_COLLATION_NAME 'collation' FROM information_schema.SCHEMATA;` [Sample result (pic)](https://i.imgur.com/TB7gotn.png) 4. ####Back up your database before running any of the following commands. That said, all you need to do is run the following commands one after the other (replace **throat** with the name of your Phuks database). Notice that we are altering the whole database PLUS the exsiting data in the `sub_post_comment`, `sub_post`, `sub`, and `message` tables. - `ALTER DATABASE throat CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;` **Sample RESULT:** Query OK, 1 row affected (0.00 sec) - `SET FOREIGN_KEY_CHECKS = 0;` **Sample RESULT:** Query OK, 0 rows affected (0.00 sec) - `ALTER TABLE sub_post_comment CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;` **Sample RESULT:** Query OK, 343 rows affected (0.10 sec) **Sample RESULT:** Records: 343 Duplicates: 0 Warnings: 0 - `ALTER TABLE sub_post CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;` **Sample RESULT:** Query OK, 244 rows affected (0.08 sec) **Sample RESULT:** Records: 244 Duplicates: 0 Warnings: 0 - `ALTER TABLE sub CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;` **Sample RESULT:** Query OK, 24 rows affected (0.03 sec) **Sample RESULT:** Records: 24 Duplicates: 0 Warnings: 0 - `ALTER TABLE message CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;` **Sample RESULT:** Query OK, 314 rows affected (0.09 sec) **Sample RESULT:** Records: 314 Duplicates: 0 Warnings: 0 - `SET FOREIGN_KEY_CHECKS = 1;` **Sample RESULT:** Query OK, 0 rows affected (0.00 sec)

No comments, yet...