如何设置远程连接:

登录到MySQL服务器端,在mysql库下执行:

  1. grant all privileges on . to ‘username’@’%’ identified by ‘password’ with grant option;

    修改密码

    mysql5.7以前:

  2. update user set password=password(‘newPassword’) where user=’root’;

mysql5.7:

  1. update user set authentication_string=password(‘newPassword ‘) where user=’root’;
  2. #或者
  3. alter user ‘root’@’localhost’ identified by ‘newpassword’;

    查看MySQL的字符集设置

  4. show global variables like “%character%”;

改变

  1. SET global character_set_client=’utf8’;
  2. SET global character_set_server=’utf8’;
  3. SET global character_set_database=’utf8’;
  4. SET global character_set_connection=’utf8’;
  5. SET global character_set_results=’utf8’;
  6. SET global character_set_client=’utf8mb4’;
  7. SET global character_set_server=’utf8mb4’;
  8. SET global character_set_database=’utf8mb4’;
  9. SET global character_set_connection=’utf8mb4’;
  10. SET global character_set_results=’utf8mb4’;

    创建用户:

  11. create user ‘username’@’%’ identified by ‘password’;

    新增授权:

  12. grant select, insert, update, references, delete, create, drop, alter, index, trigger, create view, show view, execute, alter routine, create routine, create temporary tables, lock tables, event on database_name.* to ‘username’@’%’;

    修改授权:

  13. revoke select, insert, update, references, delete, create, alter, index, trigger, create view, show view, execute, alter routine, create routine, create temporary tables, lock tables, event on database_name.* from ‘username’@‘%’;

    删除用户:

  14. drop user username@‘%’

    创建用户:

  15. GRANT USAGE ON . TO ‘username’@’%’ IDENTIFIED BY ‘password’

  16. WITH MAX_QUERIES_PER_HOUR 0
  17. MAX_UPDATES_PER_HOUR 0
  18. MAX_CONNECTIONS_PER_HOUR 0;
  19. GRANT Create Routine, Insert, Lock Tables, References, Select, Drop, Delete, Index, Alter Routine, Create View, Create Temporary Tables, Show View, Trigger, Event, Create, Update, Execute, Alter ON database name.* TO username@%;