MySQL 8 服务器插件

安装插件

内置插件时服务器能够自动识别的,通常在服务器启动时加载内置插件。

在mysql.plugin表中注册的插件,这种插件不同于内置插件(内置插件不需要注册),通常在服务器启动时会加载mysql.plugin表中的插件,同时会启用这些插件。

使用命令行选项指定的插件:

--plugin-load 选项:以分号分隔插件,最后一个--plugin-load生效

--plugin-load-add:对plugin-load 选项的补充

注:这两个选项都是在内置插件、存储引擎加载后加载

--early-plugin-load:

这个选项是在内置插件、存储引擎加载前加载

这三个选项指定的插件都不会注册到mysql.plugin表中,所有如果在服务器重启后也能够使用,可以将其写到选项文件中。

比如:

[mysqld]

plugin-load=myplugin=somepluglib.so

在服务器运行时,通过INSTALL PLUGIN语句安装插件,通过这种方式安装的插件会注册到mysql.plugin表中。比如:

INSTALL PLUGIN myplugin SONAME 'somepluglib.so';

注:如果插件不能再运行时通过INSTALL PLUGIN语句安装,可以通过--load-plugin方式加载插件到服务器中。

在服务器启动时控制插件ACTIVATION状态:

--plugin_name=OFF
Tells the server to disable the plugin.

This may not be possible for certain built-in plugins, such as mysql_native_password.

--plugin_name[=ON]
Tells the server to enable the plugin. (Specifying the option as --plugin_name without a value has the same effect.) If the plugin fails to initialize, the server runs with the plugin disabled.

--plugin_name=FORCE
Tells the server to enable the plugin, but if plugin initialization fails, the server does not start. In other words, this option forces the server to run with the plugin enabled or not at all.

--plugin_name=FORCE_PLUS_PERMANENT
Like FORCE, but in addition prevents the plugin from being unloaded at runtime. If a user attempts to do so with UNINSTALL PLUGIN, an error occurs.

可以通过INFORMATION_SCHEMA.PLUGINS表的LOAD_OPTION列查看插件ACTIVATION状态。

卸载插件

UNINSTALL PLUGIN语句可以卸载通过INSTALL PLUGIN或者PLUGIN-LOAD方式加载的插件。但是不能卸载内置插件(INFORMATION_SCHEMA.PLUGINS表PLUGIN_LIBRARY字段为NULL的插件),也不能卸载INFORMATION_SCHEMA.PLUGINS表load_option字段为FORCE_PLUS_PERMANENT的插件。

注:在卸载通过PLUGIN-LOAD方式加载的插件时,注意要将my.cnf配置文件中相关配置删除,否则下次启动时仍然会加载该插件。

查看插件信息

SHOW PLUGINS

INFORMATION_SCHEMA.PLUGINS

MYSQL.PLUGIN

猜你喜欢

转载自www.cnblogs.com/xinzhizhu/p/12319729.html