Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of garbled code on MySQL command line

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains the "MySQL command line garbled problem how to solve", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "MySQL command line garbled problem how to solve" it!

How to solve the problem of garbled code on MySQL command line

On the MySQL command line, enter: showvariableslike'character_set_%'

View the currently configured encoding

On the MySQL command line, enter: setnamesutf8

Is equivalent to

Setcharacter_set_client=utf8

Setcharacter_set_results=utf8

Setcharacter_set_connection=utf8

These three orders

Before inserting data on the command line

Execute the command setnamesgbk; or setnamesgb2312

Re-insert

Before querying the data

Execute the command setnamesgbk; or setnamesgb2312

Setnamesutf8 after that.

In this way, you can insert and query Chinese normally and keep the database code as utf8.

How to solve the login error of MySQL command line

When MySQL was first installed, the way to log in to MySQL on the MySQL command line was mysql-uroot-ppassword

For example: mysql-rroot-p123456

But the strange thing is that this command is wrong for me to enter it dead or alive. It will ask me to enter the password again and return it.

ERROR1049 (42000): Unknowndatabase'123456'

The error is obvious that the password after our-P represents the database name. But the parameter-p, p should represent the meaning of password, which puzzled me before. After I logged on to MySQL, I always used

C:\ > mysql-uroot-p

Enterpassword:*

This format.

Until today, I suddenly found a post:

Mysql-rroot-p123456

-p and password are linked together, try it quickly, you can log in as expected!

One is careless and has been misled for so long. How did I find out that it was full of-p formats followed by a space?

PS:-r can be followed by a user name or a space, but the password must not be followed by a space.

Format:

Mysql-rroot-p123456

Mysql-rroot-p123456

Thank you for reading, the above is the content of "how to solve the MySQL command line garbled problem". After the study of this article, I believe you have a deeper understanding of how to solve the MySQL command line garbled problem, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report