将mysql数据导入mongodb

发布于:2013-11-21 16:07 作者:admin 浏览:1812 分类:Linux

1、进入Mysql,将数据导成CVS

select * from test_info into outfile '/tmp/test.csv' fields terminated by ',' optionally enclosed by '"' escaped by '"' lines terminated by '\r\n';


2、将CVS导入到Mongodb中
#./bin/mongoexport -h "127.0.0.1:16688" -u"username" -p "password" -d "test" -c "test_info" -f "id,name" -type=csv -file="/tmp/test.csv" 

标签: mysql mongodb

0

MySQL开启慢查询

发布于:2013-11-1 16:21 作者:admin 浏览:1666 分类:Linux

查看/设置“慢查询”的时间定义
mysql> show variables like "long%";
+-----------------+----------+
| Variable_name   | Value    |
+-----------------+----------+
| long_query_time | 1      |
+-----------------+----------+
1 row in set (0.00 sec)


如上述语句输出,“慢查询”的时间定义为1秒(方便测试,一般设置为1-10秒)。使用下面语句定义“慢查询”时间

mysql> set long_query_time=1;
Query OK, 0 rows affected (0.00 sec)


开启“慢查询”记录功能
mysql> show variables like "slow%";
+---------------------+------------------------------------+
| Variable_name       | Value                              |
+---------------------+------------------------------------+
| slow_launch_time    | 2                                  |
| slow_query_log      | OFF                                |
| slow_query_log_file | /opt/mysql/data/localhost-slow.log |
+---------------------+------------------------------------+
3 rows in set (0.00 sec)


上述语句查看“慢查询”的配置信息,你可以自定义日志文件的存放,但必须将 slow_query_log 全局变量设置为“ON”状态,执行以下语句:

mysql> set global slow_query_log=ON;
Query OK, 0 rows affected (0.01 sec)

结果:

mysql> show variables like "slow%";
+---------------------+------------------------------------+
| Variable_name       | Value                              |
+---------------------+------------------------------------+
| slow_launch_time    | 2                                  |
| slow_query_log      | ON                                 |
| slow_query_log_file | /opt/mysql/data/localhost-slow.log |
+---------------------+------------------------------------+
3 rows in set (0.00 sec)

 

标签: mysql 慢查询

0

1 2