Multi-instance configuration of mysql5.7.11
Multi-instance configuration of mysql5.7.11
Mysql has been cleared for a long time and finally reached the second stage. It’s time to do something interesting. I searched on Baidu and found that many of the multi-instances are 5.5, and the 5.7 instructions are not detailed and clear, so I made a simpler tutorial. PS: This is my first time using Markdown; to save time, I installed the rpm package; my level is limited, please correct me; it is not compatible with Mysql5.5.
What you will see are:
Preparation for configuring Mysql multiple instances
Start multiple Mysql instances
Connect Mysql
Some simple settings (optional)
Close Mysql
Add another Mysql instance
1. Preparation for configuring multiple Mysql instances
1.1 创建文件目录 打算运行两个实例,一个占用3306端口,一个占用3307端口,下面简称3306,3307实例 mkdir -p /mysql_multi/{3306,3307}/data 由于是root创建的还要把权限更改下,这步先放一放留到2.1。 1.2 准备配置文件 vim编辑两个my.cnf配置文件,编辑完后可以按ZZ或者wq!直接保存退出: 简单来说就是1.端口不一样 2.目录路径不同 实例1的配置文件: datadir=/mysql_multi/3306/data socket=/mysql_multi/3306/mysql.sock log-error=/mysql_multi/3306/mysqld.log pid-file=/mysql_multi/3306/mysqld.pid server-id=1 port=3306 实例2的配置文件: datadir=/mysql_multi/3307/data socket=/mysql_multi/3307/mysql.sock log-error=/mysql_multi/3307/mysqld.log pid-file=/mysql_multi/3307/mysqld.pid server-id=2 port=3307 分别copy到/mysql_multi/3306和/mysql_multi/3307下
2. Start multiple Mysql instances
2.1 初始化两个Mysql数据库 先改下目录的权限: chown -R mysql:mysql /mysql_multi 现在是Mysql5.7,之前的5.5都没有这一步。 对于3306,执行: mysqld --defaults-file=/mysql_multi/3306/my.cnf --initialize-insecure --user=mysql 解释: --defaults-file=/mysql_multi/3306/my.cnf :指定启动的配置文件 --initialize-insecure :初始化数据库,加上-insecure不生成随机密码 (直接登陆,不加上-insecure会在mysqld.log生成密码,到时候要自己找 temporary password) --user=mysql : 指定用户,这个没什么好说 3307的也一样: mysqld --defaults-file=/mysql_multi/3307/my.cnf --initialize-insecure --user=mysql 要注意查看data目录下面有没有相关的数据库文件,如果有问题,要看下你的mysqld.log 2.2 启动实例 终于到启动实例的关键时刻 输入: 启动3306实例:mysqld --defaults-file=/mysql_multi/3306/my.cnf --user=mysql & 启动3307实例:mysqld --defaults-file=/mysql_multi/3307/my.cnf --user=mysql & 注意:最后面要加入 &让它运行在后台,不然打完按回车就"卡住"了 和刚刚差不多就是少了--initialize-insecure初始化数据库这一步,运行成不成功可以看下mysql.log或者 输入netstat -ntlp 查看下占用端口的进程(成功就可以看到两个mysqld进程,分别占用3306,3307端口)
3. Connect to Mysql
连接 连接3306:mysql -uroot -p -S /mysql_multi/3306/mysql.sock 提示输入密码,直接回车进入。 连接3307:mysql -uroot -p -S /mysql_multi/3307/mysql.sock 和上面是一样的 可以输入 system mysql -S /mysql_multi/3307/mysql.sock切换实例
4. Some simple settings (optional)
从管理角度来讲,应该要加个system的管理员用作远程管理 grant all privileges on *.* to system@'%' identified by '12345678' with grant option;
5. Shut down Mysql
注意:一定要用mysqladmin关闭 mysqladmin -S /mysql_multi/3306/mysql.sock shutdown mysqladmin -S /mysql_multi/3307/mysql.sock shutdown
6 .Add another Mysql instance
1. 创建相关目录 mkdir -p /mysql_multi/3308/data 2.更改所属用户和所属组 chown -R mysql:mysql 3308 3.复制修改配置文件(不细说了) 4.初始化: mysqld --defaults-file=/mysql_multi/3308/my.cnf --initialize-insecure --user=mysql 5.启动:mysqld --defaults-file=/mysql_multi/3308/my.cnf --user=mysql &
complete~ Finally, a few words: mysqld_safe cannot be found after a certain version of mysql5.7 (Baidu says it is 5.7.9).

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA
