网络编程-Mysql-1、数据库的启动关闭,创建数据库,表等基本操作

启动服务端:sudo service mysql start

关闭服务端:suodo service mysql stop

重启服务端:suodo service mysql restart

连接数据库:mysql -uroot -p密码

断开连接:Ctrl+d

查看数据库版本:select version();

查看数据库时间:select now();

查看所有数据库:show databses;

使用数据库:use 数据库名;

创建数据库:create datbases 数据库名 charset=utf8;

创建数据表:例如创建一个学生表:creat table student (id int auto_increment not null permary key ,name varchar(5) not null ,sex enum('男','女') not null default ‘保密’)

增加表字段:alter table student add birthday datatime not null;

修改表字段:alter table student modify birthday datanot null;

查看表结构:desc 表名;

查看创建表语句:show creat table student;

往表里插入数据:insert into student values(1,'张三','男')

原文地址:https://www.cnblogs.com/lz-tester/p/9509776.html