Log in to the MySQL database from the external network as a normal user

1. Log in to the database

    mysql -u root -p [superuser password];

2. Create a user

    CREATE USER 'username'@'host' IDENTIFIED BY 'password';

  Parameter Description:

  1. username: the username you will create;

  2. host: Specify the host on which the user can log in. If it is a local user, localhost can be used. If you want the user to log in from any remote host , you can use wildcards%;

  3、password: the user's login password, the password can be empty, if it is empty, the user does not need a password to log in to the server.

3. Authorize users

    Grant privileges ON databasename.tablename TO 'username'@'host';

  Parameter Description:  

  1. Privileges: the user's operating permissions, such as SELECT, INSERT, UPDATEetc., if you want to grant the permissions, useALL;

  2. databasename: database name;

  3, tablename: table name, if you want to grant the user the corresponding operation permissions on all databases and tables, it can be *expressed, such as*.*。

  The user authorized by the above command cannot authorize other users. If you want the user to be authorized, use the following command:

    GRANT privileges ON databasename.tablename TO 'username'@'host' WITH GRANT OPTION;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324985046&siteId=291194637