mysql> show global status like "%tmp%tables"; +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | Created_tmp_disk_tables | 0 | -- 内存放不下,转成磁盘存储的数量,如果过大,考虑增大内存参数 | Created_tmp_tables | 4 | -- 创建临时表的数量 +-------------------------+-------+ 2 rows in set (0.00 sec)
mysql> showvariableslike'tmpdir'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | tmpdir | /tmp | -- memory转成磁盘存储的路径 +---------------+-------+ 1 row in set (0.00 sec)
[root@MyServer ~]> mysqld_multi start [root@MyServer ~]> mysqld_multi report Reporting MySQL servers MySQL server from group: mysqld1 is running MySQL server from group: mysqld2 is running MySQL server from group: mysqld3 is running MySQL server from group: mysqld4 is running [root@MyServer ~]> netstat -tunlp | grep mysql [root@MyServer ~]> netstat -tunlp | grep mysql tcp 0 0 :::3307 :::* LISTEN 6221/mysqld tcp 0 0 :::3308 :::* LISTEN 6232/mysqld tcp 0 0 :::3309 :::* LISTEN 6238/mysqld tcp 0 0 :::3306 :::* LISTEN 6201/mysqld
-- -- mysql1 -- mysql> show variables like "port"; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | port | 3306 | +---------------+-------+ 1 row in set (0.00 sec)
mysql> showvariableslike"socket"; +---------------+------------------+ | Variable_name | Value | +---------------+------------------+ | socket | /tmp/mysql.sock1 | +---------------+------------------+ 1 row in set (0.01 sec)
mysql> showvariableslike"datadir"; +---------------+---------+ | Variable_name | Value | +---------------+---------+ | datadir | /data1/ | +---------------+---------+ 1 row in set (0.00 sec)
-- -- 这样才能进行关闭数据库的操作 -- 和[mysqld_multi]中的user,pass(注意在5.7.9中不是password)对应起来 (类比[client]标签) -- 一会测试federated链接,需要增加federated参数,并重启mysql2 -- mysql> createuser'multi_admin'@'localhost'identifiedby'123'; Query OK, 0 rows affected (0.00 sec) mysql> grant shutdown on *.* to 'multi_admin'@'localhost';
mysql> create table book ( -> id int not null auto_increment, -> name varchar(128) not null, -> primary key(id) -> ); Query OK, 0 rows affected (0.20 sec)
mysql> insert into book values(1, "book1"); Query OK, 1 row affected (0.02 sec)
mysql> select * from book; +----+-------+ | id | name | +----+-------+ | 1 | book1 | +----+-------+ 1 row in set (0.00 sec)
mysql> show variables like "port"; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | port | 3307 | -- msyql2 实例端口 +---------------+-------+ 1 row in set (0.01 sec)
mysql> showengines; +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | Engine | Support | Comment | Transactions | XA | Savepoints | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | MyISAM | YES | MyISAM storageengine | NO | NO | NO | | CSV | YES | CSV storageengine | NO | NO | NO | | PERFORMANCE_SCHEMA | YES | PerformanceSchema | NO | NO | NO | | BLACKHOLE | YES | /dev/nullstorageengine (anything you write to it disappears) | NO | NO | NO | | MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO | | InnoDB | DEFAULT | Supports transactions, row-level locking, andforeignkeys | YES | YES | YES | | ARCHIVE | YES | Archivestorageengine | NO | NO | NO | | MEMORY | YES | Hash based, storedinmemory, useful fortemporarytables | NO | NO | NO | | FEDERATED | YES | Federated MySQL storageengine | NO | NO | NO | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ 9rowsinset (0.00 sec) -- -- 显示 federated 已经启用 -- mysql> createdatabase federated_test; Query OK, 1 row affected (0.00 sec)
mysql> use federated_test; Database changed
mysql> create table federated_table_1 ( -> id int not null auto_increment, -> name varchar(128) not null, -> primary key(id) -> ) engine=federated -> connection='mysql://burn:123@127.0.0.1:3306/burn/book'; Query OK, 0 rows affected (0.04 sec)
mysql> select * from federated_table_1; +----+-------+ | id | name | +----+-------+ | 1 | book1 | -- 和 mysqld1 上的内容一致。 +----+-------+ 1 row in set (0.00 sec) -- -- 由于只有select权限,无法对该表进行insert操作 -- mysql> insertinto federated_table_1 values(2, "book2"); ERROR 1296 (HY000): Got error 10000 'Error on remote system: 1142: INSERT command denied touser'burn'@'127.0.0.1'fortable'book'' from FEDERATED