导出数据库(备份数据库)
mysqldump -u用户名 -p密码 -B(导入时不用穿件数据库) 数据库名 > 导出的数据库名
导入数据库:
mysql -u用户名 -p123456 < 导出的数据库名
把select查询结果导出到文本:
==首先改配置文件 /etc/my.cnf 里添加一行
secure_file_priv=’’
重启进入mysql
执行 select * into outfile ‘导出到mysql有权限访问的目录下’ 数据库名.表名
mysql 语句进阶:
in运算符(用于where语句中,支持多种选择):
例如:找出价格是60,50,70的记录
mysql> select * from books where price in (50,60,70);
not int 与in相反
between … and… 范围运算
例如:查找价格在30到60之间(包含30和60)的书名和价格
mysql> select bname,price from books where price between 30 and 60;
前面加not是取反
mysql 子查询(嵌套查询):
就是把两个select语句结合起来
例如:查询books里编号是category表里网络技术的编号:
mysql> select * from books where bTypeId=(select bTypeId from category where bTypeName=‘网络技术’);