MySQL can be connected using localhost, but cannot be connected using IP addresses.
Problems frequently encountered during java web Development: mysql can only be connected using localhost or 127.0.0.1
Solution: After mysql is installed, it is the root user by default. the root user can only log on to the server and needs to be assigned a new user.
1. log on to the mysql database as the root user.
2. run the following command to assign a new user:
Grant all privileges on *. * to 'username '@ 'IP Address 'identified by 'password ';
'All privileges': all permissions can also be written as select, update, and so on.
*. * All tables in all databases, such as databasename .*.
The IP address of the IP database.
Identified by 'password' indicates a password connection.
3. run the preceding command to refresh the permission.
Flush privileges;
4. modify my. conf configuration
[Mysqld]... bind_address = 127.0.0.1 # Block this...
5. restart mysql
5. 1. stop: Enter
sudo /etc/init.d/mysql stop
5. 2. start: Enter
sudo /etc/init.d/mysql start