首页 / MYSQL / mysql数据库应用管理
mysql数据库应用管理
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了mysql数据库应用管理,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2235字,纯文字阅读大概需要4分钟。
内容图文
insert
测试表mysql> show create table test\G
create table test(
id int(4) not null AUTO_INCREMENT,
name char(20) not null,
primary key(id)
);
mysql> insert into test(id,name) value(1,‘hequan‘);
mysql> select * from test;
mysql> insert into test(name) value(‘hequan‘); //ID是自增的,可以插name
mysql> insert into test value(3,‘hequna‘),(4,‘hequan‘); // 不给列,直接按顺序插入
mysqldump -uroot -p123456 -B oldboy >/tmp/oldboy_bak.sql //备份数据库 备份用检查一遍
grep -E -v "#|\/|^$|--" /tmp/oldboy_bak.sql
select from where
mysql> select id,name from test where name=‘hequan‘ and/or id=4;
mysql> select id,name from test limit 0,2; //从第0行开始,查2行
mysql> select id,name from test where id>2 and id<4;
mysql> select id,name from test order by id asc/desc;
多表查询
mysql> select student.Sno,student.Sname,course.Cname,SC.Grade from student,course,SC where student.Sno=SC.Sno and course.Cno=SC.Cno order by Sno ;
mysql> explain select * from test where name=‘hequan‘\G;//执行过程 判断有么有走索引
possible_keys: NULL
rows: 2
mysql> create index index_name on test(name);
possible_keys: index_name
rows: 1
update
mysql> update test set name=‘xx‘ where id=4 ;
mysql -uroot -p123456 oldboy < /tmp/oldboy_bak.sql //恢复数据,增量恢复。
增量恢复
#log-bin=mysql-bin 打开
/application/mysql/data/mysql-bin-hequan.000001
mysqlbinlog mysql-bin-hequan.000001
mysqladmin -uroot -p123456 flush-log 切割日志
mysql-bin-hequan.000002
mysqlbinlog -d oldboy mysql-bin-hequan.000001 >bin.sql
把错误的语句删除掉
mysql -uroot -p123456 oldboy <bin.sql
binlog只记录主数据库更改
delete
mysql> delete from test where id=3; > <
mysql> truncate table test; //清空表
更改表的字段
mysql> alter table test add sex char(4) after name; //在name后面添加sex // first
mysql> rename table test to test1;
mysql> alter table test1 rename to test;
mysql> drop table test;
乱码
650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" />
set names latin1
cat /etc/sysconfig/i18n //系统环境
LANG="zh_CN.UTF-8"
vim /etc/my.cnf //服务器端 和客户端
[client]
default-charater-set=latin1
[mysqld]
character-set-server=utf8 //5.5版本
ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8
本文出自 “何全” 博客,请务必保留此出处http://hequan.blog.51cto.com/5701886/1773918
原文:http://hequan.blog.51cto.com/5701886/1773918
内容总结
以上是互联网集市为您收集整理的mysql数据库应用管理全部内容,希望文章能够帮你解决mysql数据库应用管理所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。