MySQL Database basics

Source: Internet
Author: User

    1. Install MySQL

[email protected] ~]# yum install MySQL mysql-server mysql-devel

2. Start MySQL and set the boot from start

[[Email protected] ~]# service mysqld start/stop/restart/status #启动/shutdown/restart/status Chkconfig mysqld on/off[[email protecte D] ~]# chkconfig--list | grep mysqldmysqld 0:off1:off2:on3:on4:on5:on6:off

3. Related configurations

/etc/my.cnfmysql configuration file/var/lib/mysqlmysql database file port:3306mysql default port

5. Precautions

Mysql> quit #quit, exit, equivalent to ctrl+cbye[[email protected] ~]#; #MySQL a large log statement ends with a semicolon, note that it is a semicolon in English mode. Characters and strings are caused by ' ';

4.mysql Initialization and Login

[[email protected] ~]# mysql-u root-p ' 123456 ' [[email protected] ~]# mysql-u root-p-h localhost "-H" Specify service Address of the device

5. Create, view , and delete the current database

mysql> CREATE DATABASE Ultraera; Query OK, 1 row Affected (0.00 sec) mysql> SHOW databases;+--------------------+| Database |+--------------------+| Information_schema | | MySQL | | Test | | Ultraera |+--------------------+4 rows in Set (0.00 sec) mysql> DROP DATABASE Ultraera; Query OK, 0 rows Affected (0.00 sec)

6. Create, view, and delete the current table

#创建表格之前要先选择数据库mysql > use ultraera;Database changedmysql> CREATE TABLE  Ultraera (                           #create   Create a table with at least 1 columns     ->  id int NOT NULL,                                            #NOT  NULL   not empty,int  integral type     -> name char ( NOT NULL,      )                       #char ()   character  , () defines the character length within     -> age int not null ,     -> ); query ok, 0 rows affected  (0.01 sec) mysql> desc ultraera;+-------+- ---------+------+-----+---------+----------------+| field | type     |  Null | Key | Default | Extra           |+-------+----------+------+-----+---------+----------------+| id     | int (one)   | NO  |     | NULL     |                | |  name  | char ( | no  |     | null)     |                 | |  age   | int (one)   | no  |     |  null    |                 |+-------+----------+------+-----+---------+----------------+3 rows in set  ( 0.00 SEC) mysql> drop table ultraera ; query ok, 0 rows affected  (0.00 SEC)


This article is from the "South African Tribe" blog, please be sure to keep this source http://ultraera.blog.51cto.com/6640392/1583524

MySQL Database basics

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.