linux下程式JDBC串連不到mysql資料庫

來源:互聯網
上載者:User

標籤:java   ogg   err   grant   資訊   linux   localhost   from   相關   

  今天在linux下部署一個 JavaEE項目的時候總是串連不到Mysql資料庫,檢查之後發現串連池的配置確定是對的,進入linux伺服器之後以mysql -uname -ppassword串連總是報Access denied for user ‘root‘@‘localhost‘ (using password: YES”),最終解決掉這個問題之後還是串連不上(參考:http://www.cnblogs.com/qlqwjy/p/8315802.html)。

 

  解決掉之後通過在本地的sqlyog串連都報錯,可是在linux伺服器上可以運行,用下面語句授權之後還是串連不上,並且Java程式也是串連不上

授權:

  mysql> grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘admin‘;  mysql> grant all privileges on *.* to ‘root‘@‘localhost‘ identified by ‘admin‘;  mysql> flush privileges;  

 

 查看登入使用者資訊:

mysql> select user,host,password  from mysql.user;

 

 

 此時用service myqld stop發現不起作用,也就是關不掉mysql服務,用service mysqld start啟動報錯:

Starting mysqld (via systemctl):  Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

 

 

最終通過查看mysql的錯誤記錄檔發現mysql服務一直開啟著:

mysql> show variables like ‘error_log‘;Empty set (0.00 sec)mysql> show variables like ‘log_error‘;+---------------+---------------------+| Variable_name | Value               |+---------------+---------------------+| log_error     | /var/log/mysqld.log |+---------------+---------------------+1 row in set (0.00 sec)mysql> quitBye[[email protected] logs]# cat /var/log/mysqld.log

 

錯誤記錄檔:

180119 10:01:35 mysqld_safe Logging to ‘/var/log/mysqld.log‘.180119 10:01:35 mysqld_safe A mysqld process already exists180119 10:01:37 mysqld_safe Logging to ‘/var/log/mysqld.log‘.180119 10:01:37 mysqld_safe A mysqld process already exists180119 10:01:38 mysqld_safe Logging to ‘/var/log/mysqld.log‘.180119 10:01:38 mysqld_safe A mysqld process already exists

 

 

 

 

 解決辦法:最後是通過查看mysql相關的pid然後殺死進程之後重新啟動mysql解決的:

[[email protected] logs]# ps -ef|grep mysqlmysql    24359     1  0 10:31 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usrmysql    24541 24359  0 10:31 ?        00:00:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sockroot     25420 25023  0 11:17 pts/2    00:00:00 grep --color=auto mysql[[email protected] logs]# kill -9 24541[[email protected] logs]# kill -9 24359

 

 通過上面命令查看到mysql相關的進程id之後殺掉進程,重啟mysql服務發現一切正常。

[[email protected] logs]# service mysqld start

 

linux下程式JDBC串連不到mysql資料庫

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.