After the installation of MySQL has not been configured, and then each time using the local connection, today do the test using the IP address, and then dropped the chain, has encountered before, is not a LONG memory!!!!!
Error log:
java.sql.sqlexception: null, message from server: "Host ' DUANWF ' is not allowed to connect to this mysql server "at Com.mysql.jdbc.SQLError.createSQLException (sqlerror.java:1073) at Com.mysql.jdbc.SQLError.createSQLException (sqlerror.java:987) at Com.mysql.jdbc.SQLError.createSQLException (sqlerror.java:982) At com.mysql.jdbc.mysqlio.dohandshake ( mysqlio.java:1128) At com.mysql.jdbc.connectionimpl.coreconnect (connectionimpl.java:2336) at Com.mysql.jdbc.ConnectionImpl.connectOneTryOnly (connectionimpl.java:2369) at Com.mysql.jdbc.ConnectionImpl.createNewIO (connectionimpl.java:2153) at com.mysql.jdbc.connectionimpl.< Init> (connectionimpl.java:792) at com.mysql.jdbc.jdbc4connection.<init> (JDBC4Connection.java:47) At sun.reflect.generatedconstructoraccessor2.newinstance (Unknown source) at Sun.reflect.DelegatingConstructorAccessorImpl.newInstance (Delegatingconstructoraccessorimpl.java:45) at java.lang.reflect.constructor.newinstance (Constructor.java:526) at com.mysql.jdbc.util.handlenewinstance (util.java:411) at com.mysql.jdbc.connectionimpl.getinstance ( connectionimpl.java:381) At com.mysql.jdbc.nonregisteringdriver.connect (nonregisteringdriver.java:305) at com.mchange.v2.c3p0.drivermanagerdatasource.getconnection (drivermanagerdatasource.java:135) at Com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection (Wrapperconnectionpooldatasource.java : 182) At com.mchange.v2.c3p0.wrapperconnectionpooldatasource.getpooledconnection ( wrapperconnectionpooldatasource.java:171) at com.mchange.v2.c3p0.impl.c3p0pooledconnectionpool$ 1pooledconnectionresourcepoolmanager.acquireresource (c3p0pooledconnectionpool.java:137) at Com.mchange.v2.resourcepool.BasicResourcePool.doAcquire (basicresourcepool.java:1014) at com.mchange.v2.resourcepool.basicresourcepool.access$800 (basicresourcepool.java:32) At coM.mchange.v2.resourcepool.basicresourcepool$acquiretask.run (basicresourcepool.java:1810) at Com.mchange.v2.async.threadpoolasynchronousrunner$poolthread.run (threadpoolasynchronousrunner.java:547) Java.lang.nullpointerexceptionat com.asinfo.dao.impl.superdao.update (superdao.java:113) at Com.asinfo.dao.impl.FileDaoImpl.insert (filedaoimpl.java:75) at Com.asinfo.service.impl.FoundFileServiceImpl.foundFile (foundfileserviceimpl.java:104) at Com.asinfo.service.impl.FoundFileServiceImpl.foundFile (foundfileserviceimpl.java:45) at Com.asinfo.main.Main.main (MAIN.JAVA:16)
Workaround: Turn on MySQL remote connection.
First, query the database user:
Use Mysql;select * from user;
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/47/B5/wKioL1P-pfDQcUvaAAD_qrRXUis400.jpg "title=" 1.png " alt= "Wkiol1p-pfdqcuvaaad_qrrxuis400.jpg"/>
You can see only local connection permissions.
There are three main ways to open MySQL remote connection:
I. Authorized use of fixed IP
Execute command:
Grant Select,update,insert,delete on * * to [email protected] identified by "root";
Query Result:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/47/B6/wKioL1P-pvGiUzHSAAEhUgUEFgY678.jpg "title=" 2.png " alt= "Wkiol1p-pvgiuzhsaaehuguefgy678.jpg"/>
You can see that you have added the root user's IP connection permissions in the user table. The host field represents the logged-on hosts, whose values can be either IP-enabled or host-name.
Ii. the law of authorization
You can change the value of the host field to% to indicate that you can log on to the MySQL server as the root user on any client machine, and it is recommended that you set it to% at development time. To change the permission to all privileges, execute the command:
Grant all privileges on * * to [email protected] '% ' identified by ' root ';
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/47/B6/wKioL1P-qMyQKWzQAAFftVSPWSs628.jpg "title=" 3.png " alt= "Wkiol1p-qmyqkwzqaafftvspwss628.jpg"/>
You can see that you have added a root account that can be accessed by all clients.
Iii. Direct change of table
Execute command:
Use Mysql;update user set Host = "%" where user = "root";
This way, so the client can access the native MySQL remotely.
This article is from the "forever_love_ing" blog, make sure to keep this source http://dwf07223.blog.51cto.com/8712758/1546087
MySQL for remote connection