MySQL console: output files rather than a list

Last update on June 13, 2009 09:19 AM by jak58
Published by jak58

MySQL console: output files rather than a list







MySQL console: output files rather than a list

The MySQL client command line is really powerful ...

You may have already been confronted with the difficulty of reading results that contain many columns ...
Example:
mysql> SHOW SLAVE STATUS;
+----------------------------------+---------------+-------------+-------------+---------------+------
------------+---------------------+------------------+---------------+-----------------------+---------
---------+-------------------+-----------------+---------------------------------------------+----------
----------+------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
-----------------------------------+-------------------------+-----------------------------+------------+
------------+--------------+---------------------+-----------------+-----------------+----------------+
---------------+--------------------+--------------------+--------------------+-----------------+-------
------------ +----------------+-----------------------+
| Slave_IO_State                   | Master_Host   | Master_User | Master_Port | Connect_Retry | Master_Log_File  | Read_Master_Log_Pos | Relay_Log_File   | Relay_Log_Pos | Relay_Master_Log_File | Slave_IO_Running | Slave_SQL_Running | Replicate_Do_DB | Replicate_Ignore_DB                         | Replicate_Do_Table | Replicate_Ignore_Table                                                                                                                                                                                                                                                                                                                                    | Replicate_Wild_Do_Table | Replicate_Wild_Ignore_Table | Last_Errno | Last_Error | Skip_Counter | Exec_Master_Log_Pos | Relay_Log_Space | Until_Condition | Until_Log_File | Until_Log_Pos | Master_SSL_Allowed | Master_SSL_CA_File | Master_SSL_CA_Path | Master_SSL_Cert | Master_SSL_Cipher | Master_SSL_Key | Seconds_Behind_Master |
+----------------------------------+---------------+-------------+-------------+---------------+------
------------+---------------------+------------------+---------------+-----------------------+---------
---------+-------------------+-----------------+---------------------------------------------+----------
----------+------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
-----------------------------------+-------------------------+-----------------------------+------------+
------------+--------------+---------------------+-----------------+-----------------+----------------+
---------------+--------------------+--------------------+--------------------+-----------------+-------
------------ +----------------+-----------------------+
| Waiting for master to send event | XXX.XXX.XXX.XXX | XXXX        |        3306 |            60 | mysql-bin.001632 |           156629364 | relay-bin.000825 |     156629501 | mysql-bin.001632      | Yes              | Yes               |                 |          |                    |              |                         |                             |          0 |            |            0 |           156629364 |       156629501 | None            |                |             0 | No                 |                    |                    |                 |                   |                |                     0 | 
...

In this case, you simply replace, at the end of order \ G to get a file output  :
<code>mysql> SHOW SLAVE STATUS\G


*************************** 1. row ***************************

             Slave_IO_State: Waiting for master to send event
                Master_Host: XXX.XXX.XXX.XXX
                Master_User: XXXX
                Master_Port: 3306
              Connect_Retry: 60
            Master_Log_File: mysql-bin.001632
        Read_Master_Log_Pos: 156842311
             Relay_Log_File: relay-bin.000825
              Relay_Log_Pos: 156842448
      Relay_Master_Log_File: mysql-bin.001632
           Slave_IO_Running: Yes
          Slave_SQL_Running: Yes
            Replicate_Do_DB: 
        Replicate_Ignore_DB: 
         Replicate_Do_Table: 
     Replicate_Ignore_Table: 
    Replicate_Wild_Do_Table: 
Replicate_Wild_Ignore_Table: 
                 Last_Errno: 0
                 Last_Error: 
               Skip_Counter: 0
        Exec_Master_Log_Pos: 156842311
            Relay_Log_Space: 156842448
            Until_Condition: None
             Until_Log_File: 
              Until_Log_Pos: 0
         Master_SSL_Allowed: No
         Master_SSL_CA_File: 
         Master_SSL_CA_Path: 
            Master_SSL_Cert: 
          Master_SSL_Cipher: 
             Master_SSL_Key: 
      Seconds_Behind_Master: 0
1 row in set (0.00 sec)
... 
Best answers for « MySQL console: output files rather than a list » in :
Unable to delete file: Argument list too long Show Unable to delete file: Argument list too long Solutions Xargs Command find loop for (bash) Program Perl When trying to delete a file , you receive the following error message : bash: /bin/rm: Argument list too long This is...
MySQL console on Windows: disable beep error Show MySQL console on Windows: disable beep error Issue Solution Issue When using MySQL console on Windows, each error causes a beep. Solution To disable it, you simply add the parameter-b in your connection string: mysql -b -h...
MySQL console: Redirect standard output ShowMySQL console: Redirect standard output MySQL client command must be common to you (mysql), with this small tip you should be able to redirect the output commands to any program? To do this, simply use the pager command, followed by...
List of open ports in command line ShowList of open ports in command line Whether you're running Windows or Linux / Unix, the following command in (console) will display the list of open ports on your computer: netstat -a For the use of advanced graphics tools, see What...
[MS-Dos]List the contents of a directory in a file Show[MS-Dos]List the contents of a directory in a file Intro Explanation Intro It may be convenient to make the listing of one or more directories in a file, to make a catalog of files. Under MS-DOS (or Windows by opening a...
Download CDBFview - DBF plugin for Total Commander ShowDescription The application is designed by WhiteTown Software. CDBFview is a tool which works with Total Commander, the application allows you to view DBF files in list. Simple and easy to use, the application has been awarded from various places....
Linux - User management ShowFirst step for the administrator When several people have access to a system, the administrator must manage the users. To do so, he must know the common commands and files to be configured. The important files are: the /etc/passwd file the...
Using FTP commands ShowThe FTP protocol FTP (File Transfer Protocol) is a protocol — meaning a standard language that lets two machines communicate — used so that computers of different types (or with different operating systems) can transfer files over a...