When Android connects to mySQL database through jdbc, the database refuses to connect


mysql server For security reasons, the default user is only allowed to log in through the command line.


First login to the mysql server via localhost

Change the Host field of the root user in the user table of the mysql database of mysql server to "%".

 The operation is as follows: 
  1. window+r
  2. Enter the cmd command, hit enter
  3. Enter the command: mysql -h (localhost or -u (username) -p (if there is a password, keep up with Your password)
  4. Enter the command: use mysql;
  5. Enter the command: update user set Host='%' where Host='localhost';
  6. Enter the command: flush privileges; (This command Must be executed, otherwise the configuration will not take effect)
  7. Enter the command: quit (exit)
    (Hint: Note that you need to add a semicolon after the command!)