当前位置:Gxlcms > 数据库问题 > linux下程序JDBC连接不到mysql数据库

linux下程序JDBC连接不到mysql数据库

时间:2021-07-01 10:21:17 帮助过:14人阅读

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> quit
Bye
[root@iz2ze46xi6pjjj69ailg9lz 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 exists
180119 10:01:37 mysqld_safe Logging to /var/log/mysqld.log.
180119 10:01:37 mysqld_safe A mysqld process already exists
180119 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解决的:

[root@iz2ze46xi6pjjj69ailg9lz logs]# ps -ef|grep mysql
mysql    24359     1  0 10:31 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mysql    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.sock
root     25420 25023  0 11:17 pts/2    00:00:00 grep --color=auto mysql
[root@iz2ze46xi6pjjj69ailg9lz logs]# kill -9 24541
[root@iz2ze46xi6pjjj69ailg9lz logs]# kill -9 24359

 

 通过上面命令查看到mysql相关的进程id之后杀掉进程,重启mysql服务发现一切正常。

[root@iz2ze46xi6pjjj69ailg9lz logs]# service mysqld start

 

linux下程序JDBC连接不到mysql数据库

标签:java   ogg   err   grant   信息   linux   localhost   from   相关   

人气教程排行