MySQL 学习笔记

基本操作

命令行下登录 MySQL 查看数据:

$ mysql -uUSER -p DATABASE

查看当前数据库包含哪些表:

> show tables;

查看 items 表结构定义:

> desc items;

从表中删除行:

> delete from sys_log where id=1252645;

从 posts 表中删除列:

> alter table posts drop column type_id;
> alter table posts drop column type_id, drop column category_id;

删除 posts 这个表:

> drop table posts;

MySQL 同步

跳过错误:

> show slave status\G;
> stop slave;
> set global sql_slave_skip_counter=1;
> start slave;
> show slave status\G;