1

I have created users table.

CREATE TABLE `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(255),
  `email` varchar(255),
  `hashed_password` varchar(255) NOT NULL,
  `user_avator` varchar(2000) NOT NUL,
  `avator_type` VARCHAR(10) DEFAULT 'monsterid',
  `date` DATE NOT NULL,
  `time` TIME NOT NULL,
  PRIMARY KEY (`id`)
);

Then I created a new account front end web page.
I gave :
username : ᵀᴹ°᭄ᴀɢᴇɴᴛ乂ᴀʀᴍʏ
Account was created successfully.
Now I can login by my username and password. Then I can clearly see my username as ᵀᴹ°᭄ᴀɢᴇɴᴛ乂ᴀʀᴍʏ in web-page.

But when I run sql query in terminal :
select username from users;
I got as output :

+------------------------------------------------------------------------------------+
| username                                                                           |
+-----------------------------------Ê                                              |-+
+------------------------------------------------------------------------------------+

I can't able to see my username as ᵀᴹ°᭄ᴀɢᴇɴᴛ乂ᴀʀᴍʏ. But I can login by web-page.
Why am I not able to see my username in query output?

UPDATE

Some users are saying that there is a problem in my terminal encoding..

To test this I run echo 'ᵀᴹ°᭄ᴀɢᴇɴᴛ乂ᴀʀᴍʏ'.
Output is ᵀᴹ°᭄ᴀɢᴇɴᴛ乂ᴀʀᴍʏ
So I guess there is no problem with the encoding in terminal.

Abhishek kamal
  • 319
  • 3
  • 12
  • 3
    Set correct terminal encoding (if it is possible, of course). – Akina Mar 17 '21 at 12:34
  • Yes, it's probably some encoding issue. Also, try creating a username with a very simple name, like "user". Check if that works – Brhaka Mar 17 '21 at 12:35
  • @Brhaka Yes simple word characters are displaying properly in terminal by running that query. – Abhishek kamal Mar 17 '21 at 12:37
  • I just run `echo 'ᵀᴹ°᭄ᴀɢᴇɴᴛ乂ᴀʀᴍʏ'` in terminal. It's output is displaying properly as it should be. So I guess there is no problem with the terminal. – Abhishek kamal Mar 17 '21 at 12:39

1 Answers1

0

You should take a look at encoding.

The username ᵀᴹ°᭄ᴀɢᴇɴᴛ乂ᴀʀᴍʏ is probably being stored in the database with the wrong encoding scheme. That's why a username with simpler characters work.

When you insert the username into the database, it's converted to the configured encoding (if necessary). Then, before being displayed on the web, it is converted to the "original" encoding (if necessary). E.g: If you convert the character ã and from UTF-8 to iso-8859-1, that's the result: ã. Now, if you convert ã from iso-8859-1 to UTF-8, that's the result: ã.

To fix the username issue, make sure that the username column's encoding is properly configured and that the terminal that's displaying the username is also properly configured, encoding-wise.

Take note that the username not being displayed correctly on the terminal is not necessarily an issue. As you said, it is properly working on the web, so the terminal is just not displaying the username in the encoding you expected.

Brhaka
  • 1,622
  • 3
  • 11
  • 31