Lỗ hổng SQL injection đang được xem là một trong những lỗ hổng bảo mật có độ nguy hiểm thuộc dạng cao nhất và liên tục nằm trong top 10 OWASP. Các cuộc tấn công SQL injection luôn gây ảnh hưởng nghiêm trọng tới các doanh nghiệp hay các trang web cá nhân và chúng vẫn đang tăng dần từng ngày. Do đó nhu cầu áp dụng các kỹ thuật học máy vào việc phát hiện lỗ hổng bảo mật này là một trong những ưu tiên hàng đầu hiện nay. Trong bài báo này chúng tôi sử dụng thuật toán Multinomial Naïve Bayes và K-Nearest neighbors để phân loại dữ liệu được lưu trên file logs dưới dạng văn bản nhằm phát hiện dấu hiệu SQL injection. Kết quả là thuật toán Multinomial Naïve Bayes có độ chính xác cao hơn so với thuật toán K-Nearest Neighbors trong việc phát hiện tấn công SQL injection.SQL Injection vulnerability is being considered as one of the most dangerous security vulnerabilities continuously in the top 10 OWASP. SQL Injection attacks have always seriously affected businesses or private websites and they are still increasing day by day. Due to the increasing demand, the application of machine learning techniques to detect this security breach is to solve the above problem. In this paper, we have used an algorithm called Multinomial Naïve Bayes, K-Nearest Neighbors on the log file in the form of text. As a result, the Multinomial Naïve Bayes algorithm has higher accuracy than the K-Nearest neighbors algorithm in SQL Injection attack.