windows上安装Mysql
1.设置环境变量PATH
2.配置配置文件my.ini
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=C:\wamp-all\mysql-5.7.13
# 设置mysql数据库的数据的存放目录
datadir=C:\wamp-all\sqldata
# 允许最大连接数
max_connections=20
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
cd C:\web\mysql-8.0.11\bin
mysqld install
net start mysql
初始化data目录
cd C:\web\mysql-8.0.11\bin
mysqld --initialize-insecure
安装
cd C:\web\mysql-8.0.11\bin
mysqld install
net start mysql
初始化data目录
cd C:\web\mysql-8.0.11\bin
mysqld --initialize-insecure
使用
net start mysql
登陆
mysql -hlocalhost -uroot -p
//若无密码直接回车
show databases;
exit;
CREATE DATABASE 数据库名;
show databases;
show tables;
drop database <数据库名>;
use 数据库名;
DROP TABLE runoob_tbl;
CREATE TABLE IF NOT EXISTS `user_tbl`(
`user_id` INT UNSIGNED AUTO_INCREMENT,
`user_name` VARCHAR(100) NOT NULL,
`user_sex` VARCHAR(40) NOT NULL,
`user_password` VARCHAR(20) NOT NULL,
PRIMARY KEY (`user_id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE w3c_tbl(
w_id INT NOT NULL AUTO_INCREMENT,
w_title VARCHAR(100) NOT NULL,
w_author VARCHAR(40) NOT NULL,
submission_date DATE,
PRIMARY KEY ( w_id )
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
·增
INSERT INTO runoob_tbl
(runoob_id,runoob_title, runoob_author, submission_date)
VALUES
("03","第三行数据", "菜鸡",NOW());
INSERT INTO runoob_tbl
(runoob_id,runoob_title, runoob_author, submission_date)
VALUES
("02","第一行数据", "菜鸟","2018-06-18");
·删
DELETE FROM runoob_tbl WHERE runoob_id=3;
·查
select * from runoob_tbl;
SELECT * from runoob_tbl WHERE runoob_author='菜鸡';
SELECT field1, field2,...fieldN FROM table_name1, table_name2...
[WHERE condition1 [AND [OR]] condition2.....
·改
UPDATE runoob_tbl SET runoob_title='学习 C++' WHERE runoob_id=03;
·查询表结构
desc tabl_name;