標籤: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資料庫