-2
Ubuntu 22.04 and nodejs v16.14.0 + mysql does not get encoding
encoding was utf8_general_ci and now utf8mb3_general_ci
script to check:
[https://github.com/amir248/nodejs/blob/main/app.js](https://www.stackoverflow.com/)
utf_general_ci used to be the same and is on the server, now with ubuntu 22.04 utfmb4_general_ci encoding on the home machine to add and check on the home machine.
how to solve encoding problem?
 `code: 'ER_BAD_FIELD_ERROR',
  errno: 1054
  sqlState: '42S22',
  sqlMessage: "Unknown column 'Name' in 'field list'",`
Pass numbers to write them to database is obtained with npm mysql2 on ubuntu 22.04 and nodejs 16.14.0
But as soon as I try to pass any alphabetic characters, an error occurs

`sqlMessage: "Unknown column 'новое слово' in 'field list'"`

I tried to set the encoding in the settings, but just change the file /etc/mysql/my.cnf another error occurs and nothing works.

I searched all over the Internet how to change the encoding, but it seems that the encoding should work with utf8_general_ci along with utf8mb4_general_ci

to change configuration files an error occurs and mysql does not work at all. there needs to be a proven way.

edit file /etc/mysql/my.cnf causes a new error, it’s also not so easy to figure it out, so I returned everything back, can anyone know what could be the reason and where to look?enter image description here

the problem is that it is not possible to connect mysql and node js 16.14.0 so that they work on ubuntu 22.04

8
  • 1
    I don't see how this related to encoding if you refer to a field Name which doesn't exist in your database table...
    – CherryDT
    Nov 20, 2022 at 11:04
  • If I pass numbers, then there is no such error. The numbers are written in this way. Only letters cause this error. Field : login, denoted as "name" - this is the field passed from the page of the template engine ejs Therefore, it seems that the problem is in the encoding. Nov 21, 2022 at 1:21
  • 1
    You probably don't pass the arguments correctly as prepared statement but have them directly embedded and without quotes... You need to show the code of the query.
    – CherryDT
    Nov 21, 2022 at 8:44
  • That parameter was passed incorrectly without quotes. The problem was solved by changing the quotes to these ' Nov 21, 2022 at 12:03
  • 1
    Also in my experience it's not a good mindset to think "locally it's fine, I'll fix it once it goes live". It won't happen. You will not fix it or you will forget to fix part of it. Always write every single line of code as if there would already be 300 hackers waiting to hack it the moment you click "save". Then you will write robust code in the first place and won't have to worry about it later. That's my mindset.
    – CherryDT
    Nov 22, 2022 at 7:37

1 Answer 1

0

[![You need to show the code of the query.]enter image description here2]2

Quotes are now infected. And yes. `- do not work, '- ok. yes, it was in quotes ` - an error if their error also disappeared, but they wrote down the numbers. I tried to change the quotes to these '- lo and behold! earned! Thanks for the help, it was in quotation marks.

Quotes for variables ` cause errors, so the error lies in the fact that the ' quote and ` quotes are similar but they are different, it is not immediately visible, but here lies the error.

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Nov 23, 2022 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.