export result of the query with INTO OUTFILE - mysql

I don't find the exported file into /tmp folder. Where MYSQL export that file ?
mysql> SELECT oid,t FROM mytable INTO OUTFILE '/tmp/bbb.txt' CHARACTER SET latin1 FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r\n';
ERROR 1086 (HY000): File '/tmp/bbb.txt' already exists
mysql> \q
Bye
usr#locahost:/tmp$ ls -l /tmp
total 210308
-rw------- 1 jetty jetty 0 Feb 27 2014 31020.jsvc_up
-rw------- 1 root root 2210 Dec 13 2013 apticron.hFScRvN3T6
drwxr-xr-x 2 root root 4096 May 25 2014 graphs
srwxr-xr-x 1 root root 0 Aug 6 2014 haproxy.socket
drwx------ 2 jetty jetty 4096 Feb 27 2014 hsperfdata_jetty
drwxr-xr-x 2 root root 4096 Jun 16 04:45 hsperfdata_root
drwx------ 2 usr users 4096 Jul 15 03:36 mc-usr
-rw-r--r-- 1 root root 64 Jul 5 15:18 puppet_failures
-rw-r--r-- 1 usr users 64 Jul 15 03:29 puppet_failures00
usr#locahost:/tmp$

Related

Can't start mysql and my.cnf is missing

For some reason, I can't start MySql.
$ sudo /etc/init.d/mysql start
[sudo] password for abigail:
Starting MySQL.............................................[FAILED]................................................................................
What caused this?
This is what in my /var/lib/mysql
$ ll -h /var/lib/mysql
total 1005M
-rw-rw----. 1 mysql mysql 16K Mar 28 11:08 aria_log.00000001
-rw-rw----. 1 mysql mysql 52 Mar 28 11:08 aria_log_control
-rw-rw----. 1 mysql mysql 908M Mar 31 20:10 ibdata1
-rw-rw----. 1 mysql mysql 48M Mar 31 20:09 ib_logfile0
-rw-rw----. 1 mysql mysql 48M Mar 31 20:10 ib_logfile1
-rw-rw----. 1 mysql mysql 5 Mar 28 11:09 localhost.pid
-rw-rw----. 1 mysql mysql 0 Oct 29 23:04 multi-master.info
drwx--x--x. 2 mysql mysql 4.0K Oct 29 23:01 mysql
drwx------. 2 mysql mysql 19 Oct 29 23:01 performance_schema
-rw-rw----. 1 mysql mysql 24K Mar 28 11:09 tc.log
drwx------. 2 mysql mysql 4.0K Nov 3 22:10 test
I think I might have to reinstall mysql.
my.cnf is supposed to be in /etc/my.cnf.
Check the start log for the error message, like in /var/log/mysqld.log.

Recover mysql using data folder

One of our MySQL servers died but somehow we were able to recover all the files from it. This server was a slave at one time however we stopped it being a slave so we could use it for housekeeping tasks and reports, etc.
Can someone tell me how to recover with this?
I now have these files and a backup of my.cnf
ll /root/home/recovered/mysql/
-rw-r----- 1 root root 117 Jun 1 09:30 rabney-relay-bin.000001
-rw-r----- 1 root root 26 Jun 1 09:30 rabney-relay-bin.index
-rw-r----- 1 root root 113055367168 Jun 1 10:42 ibdata1
-rw-r----- 1 root root 1073741824 Jun 1 09:33 ib_logfile0
-rw-r----- 1 root root 1073741824 Jun 1 09:33 ib_logfile1
drwx------ 2 root root 4096 Jun 1 09:30 mysql
drwx------ 2 root root 16384 Jun 1 09:30 production_copy
-rw-r----- 1 root root 3253518648 Jun 1 09:32 slowquery.log
drwx------ 2 root root 4096 Jun 1 09:30 test
I've been reading articles on Google regarding this but not sure how to do it yet.

Does GT.M save database operation command in logs file

I see that have some logs file create by gt.m but just only about mupip rundown or recover information
> root#localhost:/tmp/fis-gtm/V6.2-002_x86_64# ll total 68 drwxrwxrwt 2
> root root 4096 Jul 14 16:22 ./ drwxr-xr-x 3 root root 4096 Jul 13
> 14:32 ../
> -rw-r--r-- 1 root root 0 Jul 13 14:33 root_20150713073215UTC-20150713073319UTC_mupip_rundown
> -rw-r--r-- 1 root root 278 Jul 13 14:32 root_20150713073215UTC_mupip_recover
> -rw-r--r-- 1 root root 0 Jul 14 11:11 root_20150713073407UTC-20150714041129UTC_mupip_rundown
> -rw-r--r-- 1 root root 278 Jul 13 14:34 root_20150713073407UTC_mupip_recover
> -rw-r--r-- 1 root root 278 Jul 14 09:46 root_20150714024647UTC_mupip_recover
> -rw-r--r-- 1 root root 0 Jul 14 09:49 root_20150714024820UTC-20150714024941UTC_mupip_rundown
> -rw-r--r-- 1 root root 278 Jul 14 09:48 root_20150714024820UTC_mupip_recover
> -rw-r--r-- 1 root root 77 Jul 14 09:55 root_20150714025001UTC-20150714025500UTC_mupip_rundown
> -rw-r--r-- 1 root root 291 Jul 14 09:50 root_20150714025001UTC_mupip_recover
> -rw-r--r-- 1 root root 0 Jul 14 10:03 root_20150714030230UTC-20150714030331UTC_mupip_rundown
> -rw-r--r-- 1 root root 311 Jul 14 10:02 root_20150714030230UTC_mupip_recover
> -rw-r--r-- 1 root root 0 Jul 14 14:35 root_20150714030424UTC-20150714073509UTC_mupip_rundown
> -rw-r--r-- 1 root root 260 Jul 14 10:04 root_20150714030424UTC_mupip_recover
Where do I find logs about GTM command like : SET ^,WRIRE....?
Normal commands (Set, Write) are part of the core programming language and are not logged; they are journalled if they read or write something to disk. The question is what are you looking for?

Restore database by files from broken Ubuntu server

I'm pretty lost right now.
The RAID controller auf my server broke and all attached hard drives were corrupted. Luckily I copied the plain files off the server right before the crash (phew).
I set up the new server with Ubuntu 12.04 and a fresh mysql installation. I copied the backup off a server directly to the new one, without saving them to a windows machine (to prevent privileges errors).
My back up folder looks like this:
drwx------ 15 jensma jensma 4.0K Dec 12 18:09 .
drwxr-xr-x 76 jensma jensma 4.0K Nov 22 12:00 ..
drwx------ 2 mysql mysql 4.0K Nov 21 02:50 gamefilesenter code here
drwx------ 2 mysql mysql 4.0K Aug 5 00:17 circuitboard
-rw-r--r-- 1 mysql mysql 0 Oct 25 07:49 debian-5.5.flag
-rw-rw---- 1 mysql mysql 26M Dec 12 02:22 ibdata1
-rw-rw---- 1 mysql mysql 5.0M Dec 12 18:09 ib_logfile0
-rw-rw---- 1 mysql mysql 5.0M Dec 12 02:22 ib_logfile1
drwx------ 2 mysql mysql 4.0K Oct 25 07:49 mysql
-rw-rw---- 1 mysql mysql 6 Oct 25 07:49 mysql_upgrade_info
drwx------ 2 mysql mysql 4.0K Oct 25 07:49 performance_schema
drwx------ 2 mysql mysql 4.0K May 25 2013 phpmyadmin
drwx------ 2 mysql mysql 4.0K Jul 4 18:29 test
drwx------ 2 mysql mysql 4.0K May 19 2013 usr_web10_5
A folder contains data like this:
drwx------ 2 mysql mysql 4096 Aug 5 00:17 .
drwx------ 15 jensma jensma 4096 Dec 12 18:09 ..
-rw-rw---- 1 mysql mysql 65 Jul 10 15:04 db.opt
-rw-rw---- 1 mysql mysql 8620 Aug 1 23:38 stat.frm
-rw-rw---- 1 mysql mysql 8700 Aug 5 00:17 user.frm
I just copied the whole content to /var/lib/mysql and ran
sudo /usr/sbin/mysqld –innodb_log_file_size=5242880 –innodb_force_recovery=6
Well, the command kinda works - the shell shows up after half a minute. But the database is still empty :/
I'm pretty now to this. I do have full admin access to the server.
Any help is appreciated, thanks!

Rogue Database Appears in MySQL Show Databases

I see today that
show databases
displays an unknown database:
(msl_ampcs_v4_0_0_2g)> show databases;
+----------------------+
| Database |
+----------------------+
| information_schema |
| #mysql50#.ssh |
| global_lad
Normally when I see something like that it is due to a bad file in /var/lib/mysql:
-rw-r--r-- 1 mysql mysql 1663 Mar 17 2011 /var/lib/mysql/ca-cert.pem
drwx------ 2 mysql mysql 4096 Jun 18 15:00 /var/lib/mysql/global_lad
drwx------ 2 mysql mysql 4096 Jun 18 15:00 /var/lib/mysql/global_lad_unit_test
-rw-rw---- 1 mysql mysql 3231711232 Aug 22 07:20 /var/lib/mysql/ibdata1
-rw-rw---- 1 mysql mysql 5242880 Aug 22 07:20 /var/lib/mysql/ib_logfile0
-rw-rw---- 1 mysql mysql 5242880 Aug 21 16:25 /var/lib/mysql/ib_logfile1
-rw-rw---- 1 mysql mysql 5 Feb 21 2013 /var/lib/mysql/istsdb2.jpl.nasa.gov.pid
-rw-rw---- 1 mysql mysql 4596466 Oct 15 2010 /var/lib/mysql/istsdb2-slow.log
drwx------ 2 mysql mysql 4096 Jul 13 2011 /var/lib/mysql/msl_ampcs_v2_0_0
drwx------ 2 mysql mysql 4096 Jul 21 2012 /var/lib/mysql/msl_ampcs_v3_0_0
drwx------ 2 mysql mysql 4096 Jun 20 02:55 /var/lib/mysql/msl_ampcs_v4_0_0
drwx------ 2 mysql mysql 4096 Sep 5 19:45 /var/lib/mysql/msl_ampcs_v4_0_0_2g
drwx------ 2 mysql mysql 4096 Sep 30 2010 /var/lib/mysql/msl_gdsdb_v5_0
drwx------ 2 mysql mysql 4096 Jan 19 2011 /var/lib/mysql/msl_gdsdb_v5_5
drwx------ 2 mysql mysql 4096 Nov 21 2011 /var/lib/mysql/msl_gdsdb_v5_6
drwx------ 2 mysql root 4096 Mar 23 2010 /var/lib/mysql/mysql
srwxrwxrwx 1 mysql mysql 0 Feb 21 2013 /var/lib/mysql/mysql.sock
-rw------- 1 root root 841 Jun 10 2010 /var/lib/mysql/nohup.out
drwx------ 2 mysql mysql 4096 Feb 5 2013 /var/lib/mysql/pdpp_automation
-rw-r--r-- 1 mysql mysql 1310 Mar 17 2011 /var/lib/mysql/server-cert.pem
-rw-r--r-- 1 mysql mysql 1679 Mar 17 2011 /var/lib/mysql/server-key.pem
But nothing like that is present. The nohup shouldn't be there. But
#mysql50#.ssh
does not appear.