Linux system MySQL opens remote connection

For security, Mysql only allows users to log in locally by default. To open a remote connection, you need to do the following:

1. Connect to the Linux system remotely and make sure that the MySQL database has been installed on the Linux system.

Log in to the database. mysql -uroot -p

 

2. Create a user for remote connection

GRANT ALL PRIVILEGES ON *.* TO 'itoffice'@'%' IDENTIFIED BY 'itoffice' WITH GRANT OPTION;

(The first itoffice indicates the user name, % indicates that all computers can be connected, or a certain ip address can be set to run the connection, and the second itoffice indicates the password).

 

If you want to authorize a user to hold database-specific operation privileges:

GRANT select,insert,update,delete ON *.* TO 'itoffice'@'%' IDENTIFIED BY "itoffice";

 

3. Execute flush privileges; the command takes effect immediately

 

4. Query the user of the database (seeing the following indicates that the creation of a new user is successful)

SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;

5. Check the port number

show global variables like 'port';  

 

6. To delete user authorization, you need to use the REVOKE command

REVOKE privileges ON database[.tablename] FROM user-name;

Example:

Perform the authorization operation:
GRANT select, insert, update, delete ON 'test_db' TO 'user'@'%' IDENTIFIED BY 'use123';
then perform the delete authorization operation:
REVOKE all on test_db from user;
Note: This operation only clears The user has the relevant authorization permissions for test_db, but the user still exists.
Finally clear the user from the user table:
DELETE FROM user WHERE user='user';
reload the authorization table:
FLUSH PRIVILEGES;

7. MYSQL authority detailed classification:
global administrative authority:
FILE : read and write files on the MySQL server.
PROCESS : Show or kill service threads belonging to other users.
RELOAD : Reload the access control list, refresh the log, etc.
SHUTDOWN : Shut down the MySQL service.


数据库/数据表/数据列权限:
ALTER: 修改已存在的数据表(例如增加/删除列)和索引。
CREATE: 建立新的数据库或数据表。
DELETE: 删除表的记录。
DROP: 删除数据表或数据库。
INDEX: 建立或删除索引。
INSERT: 增加表的记录。
SELECT: 显示/搜索表的记录。
UPDATE: 修改表中已存在的记录。


特别的权限:
ALL: 允许做任何事(和root一样)。
USAGE: 只允许登录--其它什么也不允许做。

 

http://jingyan.baidu.com/article/363872ec3263236e4ba16f07.html

http://www.linuxidc.com/Linux/2013-06/86459.htm

Guess you like

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