当前位置:Gxlcms > 数据库问题 > MySQL总结(二)——常用命令

MySQL总结(二)——常用命令

时间:2021-07-01 10:21:17 帮助过:9人阅读

一、MySQL服务器
1、介绍
安装服务:mysqld -install
停止服务:net stop mysql
启动服务:net start mysql
用户名:root,密码:Password,连接数据库:
明文
mysql -h localhost -uroot -pPassword
mysql -uroot -pPassword
暗文
mysql -h localhost -uroot -p
mysql -uroot -p
退出MySQL连接:exit
退出当前命令行:\c

 

二、数据库
通用关键字,一个数据库名:db1;一个表名:table1。
1、库
查看有哪些库:show databases;
创建一个库:create database db1;
删除一个库:drop database db1;
选中一个库:use db1;
不能修改数据库的名字
2、表结构
查看有哪些表:show tables;
创建一个表table1:

 

删除一张表:drop table table1;
修改一个表名字:rename table table1 to table2;
查看一个表的结构:desc table1;
增加表的一列:alter table table1 add col1 tinyint unsigned zerofill;
删除表的一列:alter table table1 delete
修改表的一列:alter table table1 modify

MySQL总结(二)——常用命令

标签:esc   一个数据库   rename   结构   top   signed   databases   creat   art   

人气教程排行