MySQL Several FAQs summary

Source: Internet
Author: User
Tags clear screen

MySQL Several FAQs summary


One.

    1. command to clear the screen under MySQL

\! Clear;ctrl+shift+l;ctrl+l

Commands for clear screen under Linux

Clear; Ctrl+l; Shift+ctrl+l




Two. Four ways to view MySQL version

1: Under the terminal: Mysql-v. Here is the code snippet:

[Email protected] ~]$ mysql-v
MySQL Ver 14.7 distrib 4.1.10a, for Redhat-linux-gnu (i686)

2::mysql> status in MySQL;
Here is the code snippet:
mysql> status;
--------------
MySQL Ver 14.7 distrib 4.1.10a, for Redhat-linux-gnu (i686)
Connection id:416
Ssl:not in use
Current Pager:stdout
Using outfile: '
Using delimiter:;
Server Version:3.23.56-log
Protocol version:10
Connection:localhost via UNIX socket
Client characterset:latin1
Server characterset:latin1
UNIX Sockets:/tmp/mysql_3311.sock
Uptime:62 Days Hours min sec
Threads:1 questions:584402560 Slow queries:424 opens:59664208 Flush tables:1 Open tables:64 queries per second avg: 107.551

3: Find in Help
Here is the code snippet:
[[email protected] ~]$ MySQL--help | grep distrib
MySQL Ver 14.7 distrib 4.1.10a, for Redhat-linux-gnu (i686)

4: Using MySQL's functions
Here is the code snippet:
Mysql> select version ();
+-------------+
| Version () |
+-------------+
| 3.23.56-log |
+-------------+
1 row in Set (0.00 sec)



Three.

MySQL Character set

a). Display Character Set
Mysqladmin-uroot-proot Variables | grep character or


Show variables like '%char% ' in MySQL command mode;

| character_set_client | Latin1 |
| character_set_connection | Latin1 |
| Character_set_database | Latin1 |
| Character_set_results | Latin1 |
| Character_set_server | Latin1 |
| Character_set_system | UTF8 |
| Character_sets_dir | /usr/local/share/mysql/charsets/|

Database default using Latin1 (ISO-8859)


II). Configuring the Character Set

1. Configuring the character set when building the library

Create DATABASE testxxx default Charset=utf8

3. Configuring the character set when building a table

CREATE TABLE ' t_agent ' (
' ID ' smallint (5) Not NULL
) DEFAULT Charset=utf8;

4. Modifying the character Set

Windows platform
The MySQL configuration file under Windows is My.ini, generally in C:\windows\my.ini or c:\winnt\my.ini can be added directly in this file
DEFAULT-CHARACTER-SET=GBK #或gb2312, Big5,utf8
Then restart MySQL
Service MySQL Restart
Or
/etc/init.d/mysql restart
or restart it in another way, it takes effect.



Edit UNIX Platform
The MySQL configuration file under Linux is my.cnf, generally/etc/my.cnf, if not found can be found with the Find command:
Find/-iname MY.CNF
In this file, add
DEFAULT-CHARACTER-SET=GBK #或gb2312, Big5,utf8

Then restart MySQL


Note: If the startup error is as follows:

/usr/libexec/mysqld:unknown variable ' Default_character_set=utf8 '


You can replace Default-character-set=utf8 with Character_set_server=utf8 to solve this problem,


Another way to modify the default character set:

(2) Another way to modify the MySQL default character set is to use the MySQL command

mysql> SET character_set_client = UTF8;
mysql> SET character_set_connection = UTF8;
mysql> SET character_set_database = UTF8;
mysql> SET character_set_results = UTF8;
mysql> SET character_set_server = UTF8;

mysql> SET collation_connection = UTF8;
mysql> SET collation_database = UTF8;
mysql> SET collation_server = UTF8;

In general, even if you set the table MySQL default character set is UTF8 and send the query through UTF-8 encoding, you will find that the database is still garbled. The problem is on the connection connection layer. The workaround is to execute the following sentence before sending the query:

SET NAMES ' UTF8 ';

It is equivalent to the following three-sentence instruction:

SET character_set_client = UTF8;
SET character_set_results = UTF8;
SET character_set_connection = UTF8;




This article is from the "Technical Achievement Dream" blog, please be sure to keep this source http://pizibaidu.blog.51cto.com/1361909/1618728

MySQL Several FAQs summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.