how to restart mysql in database console?
how to restart mysql in database console?
You can't, as the MySQL server is shared with other users. What do you need to restart it for?
i want to change the unicodes from utf-8 to utf8mb4 for storing emojis.
.
mysql> SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE
'collation%';
+--------------------------+--------------------+
| Variable_name | Value |
+--------------------------+--------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| collation_connection | utf8mb4_general_ci |
| collation_database | utf8mb4_unicode_ci |
| collation_server | utf8_general_ci |
+--------------------------+--------------------+
10 rows in set (0.00 sec)
as you can see the collation_server, collation_connection and others fields are not utf8mb4 unicode. when i'm adding emojis i'm getting ? questionmark instead of emojis.
[edit by admin: formatting]
Can i do that?
The server settings are just defaults when you create a new table; the solution to make sure that your tables have the right character sets is to add the appropriate options to your CREATE TABLE
commands -- eg. CHARACTER SET = utf8mb4
But i convert my existing table to utf8mb4 with this command-
ALTER DATABASE database_name CHARACTER
SET = utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
But still i'm getting the above variables ...did i have to migrate with python manage.py migrate command ?
The database contains many essential data which i don't wanna lose.
The variables won't change, but the tables should now have the right character set. Where are you seeing the question marks instead of the emojis?
In adminitration page( in the posts text field) and in the html template too, which shows the content of the posts with text field.
I simply can create a post with some texts. So I create a post with some word and an emoji. It created succesfully. In the webpage I see the post with that words and a questionmark, instead of the emoji. So i checked in the administration page but their is no emoji instead of that the questionmark appears.
Have you set the character set in your settings?
DATABASES = {
'default': {
'ENGINE':'django.db.backends.mysql',
...
'OPTIONS': {'charset': 'utf8mb4'},
}
}
Yeah..i did.
Well right row i just use these command and its working right now-
ALTER TABLE tbl-name CONVERT TO CHARACTER SET utf8mb4;
Which is blindly set all the columns into utf8mb4 And in settings.py i use your code instead of mine and its working perfectly. Thank you
Thanks for letting us know!