Q: In Mysql, "Attempted reconnect 3 times. Giving up. " What should I do? A: jdbc:mysql://localhost/test?autoReconnect=true connection error : Server connection failure during transaction. Attempted reconnect 3 times. Giving up. please check with this command: mysql -p -u [dbuser] -h 127.0.0.1 [dbname] for example, mysql -p -u mydbuser -h 127.0.0.1 test After you input the password, can you connect to your mysql or not? If not, please login to your mysql with root account: mysql -p -u root mysql> GRANT ALL PRIVILEGES ON [dbname].* to [user]@127.0.0.1 identified by '[password]'; mysql> FLUSH PRIVILEGES; replace the [dbname] with your database name, replace the [user] with your database user name, replace the [password] with your database password, don't forget the last command: "FLUSH PRIVILEGES" if it still not work, please check your mysql is listenning in the default port 3306 port , and bind in your ip: 127.0.0.1 you can check with this command: netstat -a |grep mysql or netstat -a |grep 3306 if mysql is listen, it should print this message: tcp 0 0 *:mysql *:* LISTEN or you can check like this: telnet 127.0.0.1 3306 is that can connect or not ? if not, please check your /etc/mysql/my.cnf or /etc/my.cnf, is there one row with "--skip-networking" ? you need to comment it out. in the "data" directory of your MySQL server, or anywhere else (depending on how MySQL was compiled for your system). Binaries created by MySQL AB always look in /etc/my.cnf and [datadir]/my.cnf. If your MySQL server has been firewalled, you will need to have the firewall configured to allow TCP/IP connections from the host where your Java code is running to the MySQL server on the port that MySQL is listening to (by default, 3306). Please refer to: http://www.mysql.com/doc/en/Access_denied.html http://www.mysql.com/documentation/connector-j/index.html (4.3)
|