Mysql operation command garbled characters

1. After connecting the mysql service, we need to operate on its command line, first display mysql database,

database information command a, the display system: Show Database

 

b, which commands are: Create Database mydb;

 c, the selection created out of the database information, the command is: use mydb

 d, insert data, to be noted that the problem of character encoding, since encoding format configuration database does not support Chinese, so distortion problem occurs, as shown:

 So currently only supports English, as:

 E, data in the lookup table, as shown:

 2, want to solve the database language format, we need to do,

a, view command character encoding: Show Variables like 'Character%'; error occurs, as shown:

 Solve the problem of the above error:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'form mydb' at line 1、

Analysis of reasons: before and after the upgrade mysql error using the show variables appear, the need for repair operations mysql_upgrade

Solve the problem:

1, first exit mysql, exit command to execute, as shown:

2, the command line interface input: mysql_upgrade -uroot--p --force  , as shown:

 3, and then restart mysql can, as shown, which command:

Close Services:

systemctl stop mysqld.service

Start the service:

systemctl start mysqld.service

 Connect to the database command: MySQL -u root -p

3, performed show variables like 'character%'; as shown:

 4. If you need to set a password to log in the service, execute the command: the SET password for 'root' @ 'localhost' = password ( 'root');

as the picture shows:

 Exit sign in again to take effect

 

5, want to solve the problem of character character set, first into the etc directory, edit my.cnf; their situation is, can not find the file path in my.cnf, as shown:

 

 The figure can be explained not find the path, the most brutal way, to copy a file to the etc directory, file overwrite the original.

You can see the information we want, as shown:

 

 Restart the mysql database services to take effect, the command is executed: systemctl restart mysql

 

Finally, once again log in mysql, view character sets: Show the Variables like 'Character%';

 

 Spit bad one, finally solved the problem, worried a night!

Summary: The encounter problems, do not give up, after all, can solve the problem, come on!

With little hope for you!

Guess you like

Origin www.cnblogs.com/studygithub5208868/p/11486796.html