安装教程链接http://jingyan.baidu.com/article/597035521d5de28fc00740e6.html
设置好path路径后,打开DOS窗口, 连接mysql数据库(windows下不区分大小写)
1.mysql -u root -p
2.show databases;显示数据库
3.use register;使用名为register的数据库
4.show tables;显示register数据库中的表
5.describe user;对表user进行操作 == desc user
6.exit;推出
SQL语句
insert into user(username,password) values("xiaoyan","123456");插入数据
insert into user values("ff","123456");插入整行数据
delete from user where username="xiaoyan";删除数据
update user set username="xiaoyan" where username="ff";更新数据
select * from user;查询数据
命令行操作
1、建立数据库:
mysql> CREATE DATABASE 库名;
2、建立数据表:
mysql> USE 库名;
mysql> CREATE TABLE 表名 (字段名 VARCHAR(20), 字段名 CHAR(1));
3、删除数据库:
mysql> DROP DATABASE 库名;
4、删除数据表:
mysql> DROP TABLE 表名;
5、将表中记录清空:
mysql> DELETE FROM 表名;
6、用文本方式将数据装入数据表中:
mysql> LOAD DATA LOCAL INFILE “D:/mysql.txt” INTO TABLE 表名;
7、导入.sql文件命令:
mysql> USE 数据库名;
mysql> SOURCE d:/mysql.sql;
8、命令行修改root密码:
mysql> UPDATE mysql.user SET password=PASSWORD(’新密码’) WHERE User=’root’;
mysql> FLUSH PRIVILEGES;
9、修改表名: alter table 表名 rename to 新表名;
10、create table命令格式:create table <表名> (<字段名1> <类型1> [,..<字段名n> <类型n>]);
例如,建立一个名为MyClass的表:
mysql> create table MyClass(
> id int(4) not null primary key auto_increment,
> name char(20) not null,
> sex int(4) not null default '0',
> degree double(16,2));
not null是该字段不允许存在空值
11、清除密码:
mysql>use mysql;
mysql>update user set password='' where user='root'; 设置好path路径后,打开DOS窗口, 连接mysql数据库(windows下不区分大小写)
1.mysql -u root -p
3.use register;使用名为register的数据库
4.show tables;显示register数据库中的表
5.describe user;对表user进行操作 == desc user
6.exit;推出
SQL语句
insert into user(username,password) values("xiaoyan","123456");插入数据
insert into user values("ff","123456");插入整行数据
delete from user where username="xiaoyan";删除数据
update user set username="xiaoyan" where username="ff";更新数据
select * from user;查询数据
命令行操作
1、建立数据库:
mysql> CREATE DATABASE 库名;
2、建立数据表:
mysql> USE 库名;
mysql> CREATE TABLE 表名 (字段名 VARCHAR(20), 字段名 CHAR(1));
3、删除数据库:
mysql> DROP DATABASE 库名;
4、删除数据表:
mysql> DROP TABLE 表名;
5、将表中记录清空:
mysql> DELETE FROM 表名;
6、用文本方式将数据装入数据表中:
mysql> LOAD DATA LOCAL INFILE “D:/mysql.txt” INTO TABLE 表名;
7、导入.sql文件命令:
mysql> USE 数据库名;
mysql> SOURCE d:/mysql.sql;
8、命令行修改root密码:
mysql> UPDATE mysql.user SET password=PASSWORD(’新密码’) WHERE User=’root’;
mysql> FLUSH PRIVILEGES;
9、修改表名: alter table 表名 rename to 新表名;
10、create table命令格式:create table <表名> (<字段名1> <类型1> [,..<字段名n> <类型n>]);
例如,建立一个名为MyClass的表:
字段名 | 数字类型 | 数据宽度 | 是否为空 | 是否主键 | 自动增加 | 默认值 |
---|---|---|---|---|---|---|
id | int | 4 | 否 | primary key | auto_increment | |
name | char | 20 | 否 | |||
sex | int | 4 | 否 | 0 | ||
degree | double | 16 | 是 |
mysql> create table MyClass(
> id int(4) not null primary key auto_increment,
> name char(20) not null,
> sex int(4) not null default '0',
> degree double(16,2));
not null是该字段不允许存在空值
11、清除密码:
mysql>use mysql;
12、 show create table 表名;//显示建表命令行;
13、select * from table limit 5; //取出顶部5条记录;
select * from table limit m,n; //从第m条开始取,去n条记录;
14、set names 'gbk'
set names 'utf8' //明确使用何种字符集;
15、select count(*) as count_name from table //查询表中总的记录条数, as 把这个字段另命名为count_name;
http://blog.csdn.net/qianquanyiyan/article/details/8014377
修改MYSQL 表中的字段属性
例:建库建表命令行
mysql -u root -p
use mysql
create database Lab_Web;
use Lab-Web;
create table LabIntro(
id int(4) not null primary key auto_increment,
name varchar(20) not null,
content text);