Capital City Christian Church

The Inventory Database





From within the mariadb console environment, run the command below after adjusting it if needed. For example, you can change which columns are exports and in what order. You will need to change the date information in the .csv output filename.

Remember, the RDBMS has to be running and you will need credentials to access the database.

To launch the mariadb service, run the following command.

$ sudo systemctrl start mariadb

You can then log into the RDBMS and run commands from the console. Once mariadb is running, login with the following command, after which you will be prompted for the password for whichever user account you provide:

  
$ sudo mariadb -USERNAME

Then once in the mariadb console, you need to move into the proper database, in this case the inventory database.

  
use inventory;
  
/* Export the entier Inventory table to CSV format */
/* Note that you can export only into the '/var/lib/mysql-files/' directory */
select id, ifnull(ip,''),ifnull(mac,''),ifnull(name,''),
ifnull(location,''),ifnull(switch,''),ifnull(ports,''),
ifnull(type,''),ifnull(sn,''),ifnull(os,''),ifnull(firmware,''),
ifnull(dante,''),ifnull(ssid,''),ifnull(channel,''),ifnull(notes,''),
ifnull(media,''),ifnull(lastipseen,''),
ifnull(media,''),ifnull(lastipseen,''),ifnull(redflag,''),ifnull(user,''),ifnull(user,'') from inventory into outfile '/var/lib/mysql-files/inventory.csv.export.040921.1406.csv'
fields enclosed by '"' terminated by ';' escaped by '"'
lines terminated by '\r\n';