Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection


問題:維護團隊原有java項目,spring + mybatis。所在機器重啟后,重啟項目,tomcat已啟動,報以下錯

解決:

根據錯誤信息推測與數據庫有關,在Linux上執行mysql,報錯

which mysql
sh xx/bin/mysqld_safe   # xx為安裝地址

執行mysql無問題,項目仍報錯。mysql語句鏈接項目使用數據庫,報錯;鏈接另一個一直數據庫,可鏈接

進入項目所在目錄下使用的mysql文件夾,執行sh xx/bin/mysqld_safe

梳理:

mysql作為基本環境,使用環境都已安裝,上學學習數據庫相關也遺忘,梳理之。

[mysql 和 mysqld]

 mysql (sometimes referred to as the terminal monitor” or just monitor”) is an interactive program that enables you to connect to a MySQL server, run queries, and view the results. mysql may also be used in batch mode: you place your queries in a file beforehand, then tell mysql to execute the contents of the file. Both ways of using mysql are covered here. 簡單理解mysql為一條語句

mysqld, also known as MySQL Server, is the main program that does most of the work in a MySQL installation. MySQL Server manages access to the MySQL data directory that contains databases and tables. The data directory is also the default location for other information such as log files and status files.mysqld 為后台server,所有client都需要通過mysqld去連接

mysqld_safe is the recommended way to start a mysqld server on Unix. mysqld_safe adds some safety features such as restarting the server when an error occurs and logging runtime information to an error log. 啟動mysqld的腳本,讀取的是對應目錄下的etc/my.cof

【cannot connect】

A MySQL client on Unix can connect to the mysqld server in two different ways: By using a Unix socket file to connect through a file in the file system (default /tmp/mysql.sock), or by using TCP/IP, which connects through a port number. A Unix socket file connection is faster than TCP/IP, but can be used only when connecting to a server on the same computer. A Unix socket file is used if you do not specify a host name or if you specify the special host name localhost.

 

https://dev.mysql.com/doc/refman/5.7/en/can-not-connect-to-server.html

 

 
       


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM