Common MySQL commands and Problems

Source: Internet
Author: User
Tags mysql commands

Encoding Problems:

There are four factors that affect MySQL encoding,

You can run the following command to View Details:

Mysql> Use db_name;

Mysql> statue;

We can see the following encoding:

Server characterset: utf8
DB characterset: utf8
Client characterset: utf8
Conn. characterset: utf8

I don't know what these four points are, but if we unify all of them into one encoding, there will be no garbled characters:

Setting method:

Mysql> set names utf8;

If you use the source command to create tables and insert data using a script file, you must ensure that the script file is also UTF-8 encoded.

MySQL table, column addition, deletion

Add column:
Alter table table_name add column_name type;
Eg: alter table customer add memo varchar (500 );
Or: alter table customer add memo varchar (500) not null default '00 ';

Delete column:
Alter table table_name drop column column_name;
Eg: alter table customer drop column memo;

Modify column attributes:
Alter table table_name modify column_name type;
Eg: Alter customer modify memo char (300 );

Add constraints:
Add uniqueness constraint: alter table checked add constraint checked_unique_key unique (checknumber) Mysql Data Import and Export
Http://blog.chinaunix.net/uid-16844903-id-3411118.html
1. Export all data and table structures: mysqldump dbname> D:/1. SQL
2. Export the specified data and table structure: mysqldump dbname tablename1 tablename2 tablename3> D:/1. SQL
3. Only export all table structures (Table creation scripts): mysqldump-D dbname> D:/1. SQL
4. export only the specified table structure (Table creation script): mysqldump-D dbname tablename1 tablename2> D:/1. SQL
5. export only all insert statements: mysqldump-T dbname> D:/1. SQL
6. export only the insert statement of the specified table: mysqldump-T dbname tablename1 tablename2> D:/1. SQL

7, source D:/1. SQL

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.