Using machine learning to predict the intensity of pain from fMRI has attracted rapidly increasing interests. However, due to remarkable inter- and intra-individual variabilities in pain responses, the performance of existing fMRI-based pain prediction models is far from satisfactory. The present study proposed a new approach which can design a prediction model specific to each individual or each experimental trial so that the specific model can achieve more accurate prediction of the intensity of nociceptive pain from single-trial fMRI responses. More precisely, the new approach uses a supervised k-means method on nociceptive-evoked fMRI responses to cluster individuals or trials into a set of subgroups, each of which has similar and consistent fMRI activation patterns. Then, for a new test individual/trial, the proposed approach chooses one subgroup of individuals/trials, which has the closest fMRI patterns to the test individual/trial, as training samples to train an individual-specific or a trial-specific pain prediction model. The new approach was tested on a nociceptive-evoked fMRI dataset and achieved significantly higher prediction accuracy than conventional non-specific models, which used all available training samples to train a model. The generalizability of the proposed approach is further validated by training specific models on one dataset and testing these models on an independent new dataset. This proposed individual-specific and trial-specific pain prediction approach has the potential to be used for the development of individualized and precise pain assessment tools in clinical practice.