Using the MySQL CLI client.
$ mysql -u <user> -p
mysql> use <your-database>
mysql> DELETE FROM `wp_posts` WHERE `post_type` = "attachment"
Notice that I'm using
-u and username, but in
-p I'm not setting anything. MySQL will ask you for your password.
And if you're trying to use it inline, you can use
$ mysql -u <user> -p <your-database> -e "DELETE FROM `wp_posts` WHERE `post_type` = 'attachment'"
Here, notice that I'm using also
-e argument. It stands for execute.
In MySQL client you can use:
mysql> show databases;
if you want to view all dabatases in your server. And you can use:
mysql> use <database>;
mysql> show tables;
if you want to view all tables into a database.
mysql> as prompts,
$ means your Linux terminal, and
mysql>, MySQL client.