mysql download、install and use

1、Access link https://dev.mysql.com/downloads/mysql/,download mysql community server;

2、Decompress the compressed package,copy my-default.ini and rename my.ini,add content :

#########################################################
  [client]
  port=3306
  default-character-set=utf8
  [mysqld]
  port=3306
  character_set_server=utf8
  #安装路径
  basedir=D:\java\mysql
  #数据路径
   datadir=D:\java\mysql\data
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
    [WinMySQLAdmin]
   D:\java\mysql\bin\mysqld.exe
#########################################################

 

3、Add environment variable(optional)

MY_HOME:

path:%MY_HOME%\bin

 

4、Register Mysql as a Windows system service

in cmd

install:mysqld install MySQL --defaults-file="D:\java\mysql\my.ini"

uninstall:mysql remove

5、start mysql service:net start mysql

 

access to cmd

mysql -u root                 {After setting the password:mysql -hlocalhost -uroot -p123456 }

create database sales;

use sales;

 

create table product_info(

product_id  varchar(32) not null,

product_name varchar(64) not null,

product_price decimal(8,2) not null,

product_stock int not null,

product_description varchar(64),

product_icon varchar(512),

category_type int not null,

create_time timestamp not null default current_timestamp ,

update_time timestamp not null default current_timestamp on update current_timestamp,

primary key (product_id)

);

 

 

create table product_category(

category_id int not null auto_increment,

category_name varchar(64) not null,

category_type int not null,

create_time timestamp not null default current_timestamp,

updata_time timestamp not null default current_timestamp on update current_timestamp,

primary key (catagory_id),

unique key equ_catagory_type(catagory_type)

);

 

Create table order_master(
order_id varchar(32) not null,
buyer_name varchar(32) not null,
buyer_phone varchar(32) not null,
buyer_address varchar(128) not null,
buyer_openid varchar(64) not null,
order_amount decimal(8,2) not null,
order_status tinyint(3) not null default '0',
pay_status tinyint(3) not null default '0',
create_time timestamp not null default current_timestamp,
update_time timestamp not null default current_timestamp on update current_timestamp,
Primary key (order_id),
Key idx_buyer_openid (buyer_openid)

);

Create table order_detail(
detail_id varchar(32) not null,
order_id varchar(32) not null,
product_id varchar(32) not null,
product_name varchar(64) not null,
product_price decimal(8,2) not null,
product_quantity int not null,
product_icon varchar(512),
create_time timestamp not null default current_timestamp,
update_time timestamp not null default current_timestamp on update current_timestamp,
Primary key(detail_id),
Key idx_order_id(order_id)
);

posted @ 2019-03-25 11:15  Fayeloh  阅读(225)  评论(0)    收藏  举报