码迷,mamicode.com
首页 > 数据库 > 详细

mysql安装

时间:2014-10-22 21:42:29      阅读:318      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   os   ar   使用   java   

我用的是mysql绿色版。在http://www.oracle.com/index.html点击download下载masql。在MySQL Enterprise Edition 目录下点击Download from Oracle eDelivery 进登录入进行下载。

设置环境变量:在path环境中加入D:\mysql\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files (x86)\Java\jdk1.8.0_11\bin

设置配置文件:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It‘s a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir = "D:/mysql/"
datadir = "D:/mysql/data/"
# default-character-set=utf8
# port = 3306
# server_id = .....


# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

mysql_args="--explicit_defaults_for_timestamp"
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

完成后保存。

 进入命令行输入窗口(Dos命令输入)进入“D:\mysql\bin”目录下运行“mysqld -u root” 命令。

 

设置密码:mysqladmin -uroot password 密码;

登录数据库:mysql -uroot -p密码 ;

显示数据库:show databases ;

 

解决乱码问题:

建立数据库:create database mldn character set utf8 ;

建立数据表:

--选择数据库
USE test ;
--删除表
DROP TABLE member;
--创建表
CREATE TABLE member(
 mid  INT  AUTO_INCREMENT ,
 name  VARCHAR(20) NOT NULL ,
 CONSTRAINT pk_mid PRIMARY KEY(mid)
)engine=innodb;
--测试数据
INSERT INTO member(name) VALUES(‘咯咯了‘) ;

SELECT * FROM member LIMIT0,5;

 

 

 建立一个新的数据库:

--删除数据库
DROP DATABASE IF EXISTS mldn ;
--创建数据库
CREATE DATABASE mldn CHARACTER SET UTF8 ;
--使用数据库
USE mldn ;
--删除数据表 
DROP TABLE IF EXISTS emp ;
--创建数据表
CREATE TABLE emp(
   empno            INT(4)            PRIMARY KEY,
   ename            VARCHAR(10),
   job                VARCHAR(9),
   hiredate            DATE,
   sal                FLOAT(7,2)
) ;
--插入测试数据
INSERT INTO emp (empno,ename,job,hiredate,sal) VALUES (6060,,经理,2001-09-16,2000.30) ;
INSERT INTO emp (empno,ename,job,hiredate,sal) VALUES (7369,,销售,2003-10-09,1500.90) ;
INSERT INTO emp (empno,ename,job,hiredate,sal) VALUES (8964,,分析员,2003-10-01,3000) ;
INSERT INTO emp (empno,ename,job,hiredate,sal) VALUES (7698,张惠,销售,2005-03-12,800) ;
INSERT INTO emp (empno,ename,job,hiredate,sal) VALUES (7782,,分析员,2005-01-12,2500) ;
INSERT INTO emp (empno,ename,job,hiredate,sal) VALUES (7762,,销售,2005-03-09,1000) ;
INSERT INTO emp (empno,ename,job,hiredate,sal) VALUES (7839,,经理,2006-09-01,2500) ;
--显示数据
select * from emp ;
--显示数据库
show datadases ;

 

 

 

 

 

 

 

 

 

 

 

 


 

mysql安装

标签:style   blog   http   color   io   os   ar   使用   java   

原文地址:http://www.cnblogs.com/lcpholdon/p/4044306.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!