There are two ways-->
# Way one
The simplest is to follow below steps:
Step 1:
SET NAMES utf8mb4;
Step 2:
ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
Step 3:
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Step 4:
ALTER TABLE table_name CHANGE column column VARCHAR(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;
That's all!!
#Way Two (For Python)
This is a hack and its work like a charm
Step 1:
Encode your string and decode it in ASCII, and save it to your database.
content = '๐ฅณ๐ฅณ Content to be save in ๐ฅณ๐ฅณ Database ๐ฅณ๐ฅณ'
encoded_content = content.encode('unicode-escape').decode('ASCII'))
This simply store encoded_content string in DB
Step 2:
While fetch this column data to show your user, simply convert it,
here content is the data, fetched from the database.
c = bytes(encoded_content, 'utf-8')
original_content = c.decode('unicode-escape')
Done!!
ALTER TABLE Tablename CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
- Selvamani Pinsert into tablename (column1,column2,column3,column4,column5,column6,column7) values ('273','3','Hdhdhdh๐๐๐๐hzhzhzzhjzj ๆ็ฑไฝ โ',49,1,'2016-09-13 08:02:29','2016-09-13 08:02:29'
Set utf8mb4 in database connection :$database_connection = new mysqli($server, $user,$password,$database_name); $database_connection->set_charset("utf8mb4");
- Selvamani Putf8mb4
when connecting. - Rick James