How to write one comment and publish on every post using database or plugin?

It would be safer to use [wp_insert_comment()][1] rather than manually through MySQL. WP often inserts data in multiple tables – using its core functions helps ensure that all of the data gets added in all of the right tables.

I’d suggest creating a query to pull all published posts. Then, set up a foreach loop that calls wp_insert_comment() on every post, thus inserting the comment on each one.