Learn about Centmin Mod LEMP Stack today
Become a Member

Running MySQL query

Discussion in 'System Administration' started by Jon Snow, Aug 23, 2017.

  1. Jon Snow

    Jon Snow Active Member

    Jun 30, 2017
    Local Time:
    11:13 PM
    Nginx 1.13.9
    MariaDB 10.1.31
    I'm in need of running a MySQL query through an SSH client :
    DELETE FROM xf_node_type WHERE node_type_id = 'WF_WidgetPage';
    Any advice? (this is xenForo for an add-on)

    I enter the MariaDB monitor but as root and only one database is hosted on the server.
  2. eva2000

    eva2000 Administrator Staff Member

    May 24, 2014
    Brisbane, Australia
    Local Time:
    1:13 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    you'd want to backup your mysql databases before running mysql queries - especially if you're deleting data.

    otherwise you could screw up your database and data

    if you do not know how to backup your database via mysqldump, i'd read up on that first https://dev.mysql.com/doc/refman/5.6/en/mysqldump.html and bottom of page at https://centminmod.com/mysql.html :)

    for running queries you can use mysql shell as outlined at https://dev.mysql.com/doc/refman/5.6/en/mysql.html

    enter mysql shell
    Code (Text):
    mysql yourdatabasename

    at mariadb or mysql shell prompt
    Code (Text):
    mariadb>> DELETE FROM xf_node_type WHERE node_type_id = 'WF_WidgetPage';
    mariadb>> exit

    SSH command line would be
    Code (Text):
    mysql -e "DELETE FROM xf_node_type WHERE node_type_id = 'WF_WidgetPage';" yourdatabasename
    • Like Like x 1