The invention discloses a
database access method and device for preventing user data leakage in a container, and the method comprises the steps: a business service sends a connection establishment request to a
database service; a
database side vehicle service hijack connection establishment request which has the same POD with the business service and is different from the business service in a container contai ner; the database side vehicle service analyzes a database protocol, modifies a user name and a
password in the connection establishment request, and forwards the modified connection establishment request to the database service; the database service performs user name and
password verification based on the modified connection establishment request, and returns a response after the
verification is passed; and the database side vehicle service receives the response of the database service and forwards the response back to the business service, and the business service establishes
database connection with the database service. According to the invention, the database side vehicle service is introduced between the business service and the database service, all
database connection requests are intercepted, and the business service does not need to know the user name and
password of the database when connecting the database, so that the leakage of certificates is avoided.