建立MySQL镜像数据库在linux下的简单方案
以下文章主要是介绍在linux下准确建立MySQL镜像数据库 ,本文是在MySQL的版本是4.1进行操作的,如果你对在linux下准确建立MySQL镜像数据库的相当热捧的话。那么下面的文章对于你而言一定很有意义。 摘要:本文介绍如何在linux下建立MySQL镜像数据库的方法 过
以下文章主要是介绍在linux下准确建立MySQL镜像数据库 ,本文是在MySQL的版本是4.1进行操作的,如果你对在linux下准确建立MySQL镜像数据库的相当热捧的话。那么下面的文章对于你而言一定很有意义。
摘要:本文介绍如何在linux下建立MySQL镜像数据库的方法
过程,MySQL的版本是4.1。
标签:MySQL linux
Oracle帮您准确洞察各个物流环节
MySQL 版本:4.1
环境介绍:主库 192.168.0.205 从库 192.168.0.206
1、主库创建/etc/my.cnf,修改[MySQLd]里边的键值增加
<ol class="dp-xml"> <li class="alt"><span><span class="attribute">server-id</span><span>=</span><span class="attribute-value">1</span><span> </span></span></li> <li> <span class="attribute">log-bin</span><span>=</span><span class="attribute-value">binlog_name</span><span> </span> </li> </ol>
2、主库增加用户,用于从库读取主库日志。
<ol class="dp-xml"><li class="alt"><span><span>grant replication slave,reload,super on *.* to ’slave’@’192.168.0.206’ identified by ’123456’ </span></span></li></ol>
3、从库连接主库进行测试。
<ol class="dp-xml"><li class="alt"><span><span>/opt/MySQL/bin/MySQL -u slave -p -h 192.168.0.205 </span></span></li></ol>
4、停从库,修改从库/etc/my.cnf,增加选项:
<ol class="dp-xml"><li class="alt"><span><span>[MySQLd] </span><span class="attribute">server-id</span><span>=</span><span class="attribute-value">2</span><span> </span><span class="attribute">master-host</span><span>=</span><span class="attribute-value">192</span><span>.168.0.205 </span><span class="attribute">master-user</span><span>=</span><span class="attribute-value">slave</span><span> </span><span class="attribute">master-password</span><span>=</span><span class="attribute-value">123456</span><span> </span></span></li></ol>
5、启动从库,进行主从库数据同步
<ol class="dp-xml"> <li class="alt"><span><span>/opt/MySQL/share/MySQL/MySQL start </span></span></li> <li><span>/opt/MySQL/bin/MySQL -u root -p </span></li> <li class="alt"> <span>MySQL</span><span class="tag">></span><span>load data from master; </span> </li> </ol>
说明:这一步也可以用数据库倒入或者直接目录考过来。
6linux下建立MySQL镜像数据库:、进行测试:
主库创建表,
<ol class="dp-xml"><li class="alt"><span><span>MySQL</span><span class="tag">></span><span>create database sampdb; MySQL</span><span class="tag">></span><span>create table new (name char(20),phone char(20)); MySQL</span><span class="tag">></span><span>insert into new (’abc,’0532555555’); </span></span></li></ol>
打开从库,察看:
<ol class="dp-xml"><li class="alt"><span><span>/opt/MySQL/bin/MySQL -u root -p MySQL</span><span class="tag">></span><span>show database; MySQL sampdb test MySQL</span><span class="tag">></span><span>use sampdb; MySQL</span><span class="tag">></span><span>show tables; </span></span></li></ol>
new 说明主从数据库创建成功。
7、主从数据库相关命令:
<ol class="dp-xml"><li class="alt"><span><span>slave stop; slave start ; </span></span></li></ol>
开始停止从数据库。
<ol class="dp-xml"><li class="alt"><span><span>show slave status\G; </span></span></li></ol>
显示从库正读取哪一个主数据库二进制日志
<ol class="dp-xml"><li class="alt"><span><span>purge master logs to ’binlog.000004’; </span></span></li></ol>
此命令非常小心,删除主数据库没用的二进制日志文件。如果误删除,那么从库就没有办法自动更新了。
<ol class="dp-xml"><li class="alt"><span><span>change master; </span></span></li></ol>
从服务器上修改参数使用。以上的相关内容就是对linux下建立MySQL镜像数据库的介绍,望你能有所收获。

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

AI Hentai Generator
Generate AI Hentai for free.

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



VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

VS Code To switch Chinese mode: Open the settings interface (Windows/Linux: Ctrl, macOS: Cmd,) Search for "Editor: Language" settings Select "Chinese" in the drop-down menu Save settings and restart VS Code

VS Code One-step/Next step shortcut key usage: One-step (backward): Windows/Linux: Ctrl ←; macOS: Cmd ←Next step (forward): Windows/Linux: Ctrl →; macOS: Cmd →

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

VS Code supports Chinese settings, which can be completed by following the steps: Open the settings panel and search for "locale". Set "locale.language" to "zh-CN" (Simplified Chinese) or "zh-TW" (Traditional Chinese). Save settings and restart VS Code. The settings menu, toolbar, code prompts, and documents will be displayed in Chinese. Other language settings can also be customized, such as file tag format, entry description, and diagnostic process language.

Executing code in VS Code only takes six steps: 1. Open the project; 2. Create and write the code file; 3. Open the terminal; 4. Navigate to the project directory; 5. Execute the code with the appropriate commands; 6. View the output.

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

Running assembly code in VSCode requires: Install the GAS assembler. Install VSCode. Install the C/C extension. Creates a .s extension file. Write assembly code. Use the as command to compile the code. Use the ld command to link the code. Use the ./ command to run the code.
