加入收藏 | 设为首页 | 会员中心 | 我要投稿 辽源站长网 (https://www.0437zz.com/)- 云专线、云连接、智能数据、边缘计算、数据安全!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

MySQL数据库入门多实例配置

发布时间:2019-10-13 13:06:35 所属栏目:MySql教程 来源:民工哥技术之路
导读:前面介绍了相关的基础命令操作:MySQL数据库基础篇之入门基础命令 所有的操作都是基于单实例的,mysql多实例在实际生产环境也是非常实用的,因为必须要掌握。 1、什么是多实例 多实例就是一台服务器上开启多个不同的服务端口(默认3306),运行多个mysql的

启动服务

  1. [root@backup 3307]# /data/3306/mysql start  
  2. Starting MySQL...  
  3. [root@backup 3307]# lsof -i :3306  
  4. COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME  
  5. mysqld 19986 mysql 10u IPv4 90967 0t0 TCP *:mysql (LISTEN)  
  6. [root@backup 3307]# /data/3307/mysql  
  7. start Starting MySQL...  
  8. [root@backup 3307]# lsof -i :3307  
  9. COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME  
  10. mysqld 21648 mysql 11u IPv4 92899 0t0 TCP *:opsession-prxy (LISTEN) 

检查端口

  1. [root@backup 3307]# netstat -lntup|grep mysql  
  2. tcp 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN 21648/mysqld 
  3. tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 19986/mysqld 

登陆多实例数据库

  1. [root@backup ~]# mysql -S /data/3306/mysql.sock  
  2. Welcome to the MySQL monitor. Commands end with ; or g.  
  3. Your MySQL connection id is 1  
  4. Server version: 5.5.51-log Source distribution  
  5. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. 
  6. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.  
  7. mysql> create database data3306;  
  8. Query OK, 1 row affected (0.00 sec)  
  9. mysql> show databases;  
  10. +--------------------+  
  11. | Database |  
  12. +--------------------+  
  13. | information_schema |  
  14. | data3306 |  
  15. | mysql |  
  16. | performance_schema |  
  17. | test |  
  18. +--------------------+  
  19. 5 rows in set (0.00 sec)  
  20. mysql> quit  
  21. Bye  
  22. [root@backup ~]# mysql -S /data/3307/mysql.sock  
  23. Welcome to the MySQL monitor.  
  24. Commands end with ; or g.  
  25. Your MySQL connection id is 1  
  26. Server version: 5.5.51 Source distribution  
  27. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. 
  28. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.  
  29. mysql> show databases;  
  30. +--------------------+  
  31. | Database |  
  32. +--------------------+  
  33. | information_schema |  
  34. | mysql |  
  35. | performance_schema |  
  36. | test |  
  37. +--------------------+  
  38. 4 rows in set (0.05 sec) 

成功登陆,并在3306实例中创建数据库,但是3307实例上查看并没有创建过的数据,说明两个实例是独立的

注:如果再需要新增一个实例,基本的配置步骤同上述一样,只需要相应修改配置文件与启动程序文件中的端口号与数据目录的路径即可,最后可以将多实例数据库启动命令加入开机自启动。

(编辑:辽源站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读