How get all media from a posts category by db?

You could work on a WP_Query of posts of your category and then use get_attached_media to find the media of each one of the posts found. You could do a more specific query there, it’s up to you!

// WP_Query arguments
$args = array(
    'category_name'          => 'name_of_your_category',
);

// The Query
$query = new WP_Query( $args );

// The Loop
if ( $query->have_posts() ) {
    while ( $query->have_posts() ) {
        $query->the_post();
        // Adds all the media attached to each post found in the query
        // This is just an example of how you could use it!
        array_push( $your_array, get_attached_media( 'image', get_the_ID() ) );
    }
} else {
    // no posts found
}

// Restore original Post Data
wp_reset_postdata();