Simple use of MySQL

Source: Internet
Author: User

The main purpose of writing this is to record a little bit of MySQL basic use, of course, SQL query statement has a lot of things, here is not introduced, this site has a detailed tutorial (http://www.sdau.edu.cn/support/mysq_doc/manual _tutorial.html)

1. Login
mysql-h Host name-u user name-P

- H: This command is used to specify the MySQL hostname that the client wants to log on, and the parameter can be omitted when logging on to the current machine;
-U: The name of the user to log in;
- P: tells the server that a password will be used to log in, ignoring this option if the user name password you want to log in is blank
after landing you can do all kinds of operations in the command line west, pay attention to the relief to add a semicolon, otherwise he would think you did not lose a sentence.
2. Create a database
CREATE database name [other options];
CREATE database samp_db character set UTF8;
3. Select the database you want to use
Use database name
4. Create a database table
There's going to be some SQL knowledge here.
CREATE TABLE table name (column declaration);

CREATE TABLE Students
(
ID int unsigned NOT NULL auto_increment primary key,
name Char (8) is not NULL,
Sex char (4) NOT NULL,
Age tinyint unsigned is not NULL,
Tel char (+) NULL default "-"
    );
Since the statement is not very convenient to use, so you can consider the. sql file format, the method that executes from the command line
mysql-d samp_db-u root-p < Createtable.sql
    
5. Inserting Data
insert [into] table name [(column name 1, column name 2, column name 3, ...)] VALUES (value 1, value 2, value 3, ...);
6. Enquiry
Select column name from table name [query condition];

7, change the password:
mysqladmin-u root-p password New password
INSERT into students values (NULL, "Wang Gang", "Male", "13811371377");

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.