I have the following sql command which i usually run in phpmyadmin by selecting the database then running it in the command window

DELETE FROM `wp_posts` WHERE `post_type` = "attachment"

However i've never done this via terminal before. What would be the easiest way to point a command to a specific database and run it?

Best Answer


To run it from the terminal you must first be logged into mysql and then start the program The ideal code would be

mysql -u(username) -p(password) (the name of the database) -e "DELETE FROM `wp_posts` WHERE `post_type` = "attachment""

I`m sure this works, hope it helps