MySql常用命令
启动:net start mySql;
进入:mysql -u root -p/mysql -h localhost -u root -p databaseName;
列出数据库:show databases;
选择数据库:use databaseName;
列出表格:show tables;
显示表格列的属性:show columns from tableName;
建立数据库:source fileName.txt;
匹配字符:可以用通配符_代表任何一个字符,%代表任何字符串;
增加一个字段:alter table tabelName add column fieldName dateType;
增加多个字段:alter table tabelName add column fieldName1 dateType,add columns fieldName2 dateType;
多行命令输入:注意不能将单词断开;当插入或更改数据时,不能将字段的字符串展开到多行里,否则硬回车将被储存到数据中;
增加一个管理员帐户:grant all on *.* to user@localhost identified by "password";
每条语句输入完毕后要在末尾填加分号';',或者填加'\g'也可以;
查询时间:select now();
查询当前用户:select user();
查询数据库版本:select version();
查询当前使用的数据库:select database();
1、删除student_course数据库中的students数据表:
rm -f student_course/students.*
2、备份数据库:(将数据库test备份)
mysqldump -u root -p test>c:\test.txt
备份表格:(备份test数据库下的mytable表格)
mysqldump -u root -p test mytable>c:\test.txt
将备份数据导入到数据库:(导回test数据库)
mysql -u root -p test
3、创建临时表:(建立临时表zengchao)
create temporary table zengchao(name varchar(10));
4、创建表是先判断表是否存在
create table if not exists students(……);
5、从已经有的表中复制表的结构
create table table2 select * from table1 where 1<>1;
6、复制表
create table table2 select * from table1;
7、对表重新命名
alter table table1 rename as table2;
8、修改列的类型
alter table table1 modify id int unsigned;//修改列id的类型为int unsigned
alt
相关文档:
1 安装MySQL5
用下列命令安装MySQL:
yum install mysql mysql-server
然后我们为MySQL创建系统启动链接(这样的话,MySQL就会随着系统启动而启动),并启动MySQL服务器:
chkconfig –levels 235 mysqld on
/etc/init.d/mysqld start
运行
mysqladmin -u root password yourrootsqlpassword
来为root用户设置 ......
在之前的文章里,我已经提过如何解决JSP中乱码问题(解决tomcat下中文乱码问题 ),其中也详细解说了MYSQL乱码问题,相信通过里面的办法,肯定都已经解决了JSP里的乱码问题,不过还是有些人的MYSQL乱码问题没有得到解决,包括我自己,所以又找了一些资料,希望这次能完全解决MYSQL数据库的乱码问题。
......
显示mysql基本信息:mysql>status;
查看变量:show variables like '%version%';
备份与还原命令:在最后还有
1.备份MySQL数据库的命令:
在cmd中进入到mysql的lib目录下执行如下:
mysqldump -hhostname -uusername -ppassword databaseName > backupfile.sql
例:mysqldump -hlocalhost -uroot -p123456 test ......
1、mysql数据库有两种驱动:
MySQL Connector/J Driver、MMMysql driver。
2、导入导出数据库命令:(bin目录下)
导出:mysqldump -u root -p bokele >c:/mysql.sql --default-character-set=gbk
导入:C:\mysql\bin\> mysql -u root -p
说明:C:\mysql\bin\表示进入mysql程序 ......