The invention discloses a privacy budget allocating and data publishing method for protecting the data query privacy. The privacy budget allocating and data publishing method includes steps of firstly, setting privacy budget parameters, to be more specific, giving privacy budgets of data by data administrators according to importance degrees of the data, denoting the privacy budgets of the data asepsilon, setting basic query frequencies of the data and denoting the basic query frequencies of the data as k; secondly, computing privacy budgets of each query; thirdly, acquiring the sensitivity delta f of the query according to the query f submitted by users, combining the sensitivity delta f with the privacy budget epsilon allocated to the query, and computing required-to-be-added noise forquery results by the aid of difference privacy protection algorithms so as to obtain query results with the noise; fourthly, returning the query results with the noise according to the query submittedby the users so as to protect the privacy of the data. The privacy budget allocating and data publishing method has the advantages that the privacy can be protected in data publishing procedures, accomplice attack can be resisted, the precision of first k times of query can be guaranteed, and the problem of excessively low data availability due to the fact that existing privacy budgets are infinitely allocated can be solved by the aid of the privacy budget allocating and data publishing method.