MySQL BASICS (very comprehensive), MySQL BASICS (

Source: Internet
Author: User

MySQL BASICS (very comprehensive), MySQL BASICS (

MySQL Basics

I. MySQL Overview

1. What is a database?
A: Data Warehouse. For example, in the ATM example, we create a database directory called database.

2. What are MySQL, Oracle, SQLite, Access, and ms SQL Server?
A: They are both software and have two main functions:

    • A. Save the data to a file or memory
    • B. receive specific commands and perform operations on the files

3. What is SQL?
 A: MySQL and other software can accept commands and perform corresponding operations. Because the commands can include operations such as deleting files and obtaining file content, the commands written are SQL statements.

Ii. Install MySQL

MySQL is a relational database management system developed by MySQL AB in Sweden. It is currently a subsidiary of Oracle. MySQL is the most popular Relational Database Management System. In terms of WEB applications, MySQL is one of the best applications of RDBMS (Relational Database Management System.

To use MySQL to store and operate data, you need to do the following:
A. Install MySQL Server
B. Install the MySQL client
B. [client] connect to [server]
C. [client] sends a command to the [server MySQL] service to receive the command and execute the corresponding operation (add, delete, modify, query, etc)

 

Download http://dev.mysql.com/downloads/mysql/ install windows: http://jingyan.baidu.com/article/f3ad7d0ffc061a09c3345bf0.html linux: yum install mysql-server mac: Keep clicking Next

 

Client Connection

Connection: 1. The default mysql administrator is root, if you do not set a password, log on to mysql-h host-u root-p directly without entering the password and press enter to automatically enter 2. If you want to set the mysql password mysqladmin-u root password 123456 3. If your root has a password (123456 ), the command to change the password to abcdef is: mysqladmin-u root-p password abcdef exit: QUIT or Control + D

Iii. Database Basics

There are two parts:

1. create databases and tables;

2. Database and table content operations

Database Operations-Train of Thought Diagram

1. create databases and tables

(1) Create a database

1.1 display Database

1 SHOW DATABASES;

Default database:
Mysql-user permission-related data
Test-used for user test data
Information_schema-MySQL architecture data

1.2 create a database

# UTF-8 create database name default charset utf8 COLLATE utf8_general_ci; # gbk create database name default character set gbk COLLATE gbk_chinese_ci;

1.3 open a database

USE db_name;
Note: each time you use a database, you must open the corresponding database.

Display all TABLES in the currently used database: show tables;

 1.4. User Management

User settings:

Create user 'username' @ 'IP address' identified by 'Password'; delete user drop user 'username' @ 'IP address '; modify the user rename user 'username' @ 'IP address'; to 'new username' @ 'IP address ';; change password set Password for 'username' @ 'IP address' = password ('new password') PS: the user permission-related data is stored in the mysql database user table, therefore, you can directly operate on it (not recommended)

User permission settings:

Show grants for 'user' @ 'IP address' -- view the permission grant permission on the database. table to 'user' @ 'IP address' -- authorize revoke permission on database. table from 'user' @ 'IP address' -- cancel permission
All privileges all permissions except grant select only query permissions select, insert query and insert permissions... usage has no access permission. alter use alter table alter routine use alter procedure and drop procedure create use create table create routine use create procedure create temporary tables use create temporary tables create user use create user, drop user rename user and revoke all privileges create view use create view delete use delete drop use drop table execute use call and stored procedure file use select into outfile and load data infile grant option use grant and revoke index use index insert USE insert lock tables use lock table process use show full processlist select use select show databases use show databases show view use show view update use update reload use flush shutdown use mysqladmin shutdown (close MySQL) super

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.