Mysql master-slave synchronization configuration method
1. Install mysql on two Ubuntu machines
1. Check whether mysql is installed in the system
==================================
MySQL Some simple management:
启动MySQL服务: sudo start mysql 停止MySQL服务: sudo stop mysql 修改 MySQL 的管理员密码: sudo mysqladmin -u root password newpassword
1. Edit my.cnf (command to find the file location: find / -name my.cnf )
log_bin 启动MySQL二进制日志 binlog_do_db 指定记录二进制日志的数据库 binlog_ignore_db 指定不记录二进制日志的数据库。
##Comment out binlog_do_db and binlog_ignore_db, which means backing up all databasesAfter doing this After that, restart the database
2. Log in to the main server mysql and create the account and permissions used by the slave server;@After that, the IP can access the main server, and the value here is set Create a new masterbackup user with the password masterbackup from the server IP
You can see that the user masterbackup has been added
3. View The status of the master database
Record mysql-bin.000007 and 276, write the following command for later use;
3. Slave slave server configuration (103.251.237.45)
1. Edit my. cnf (command find file location: find / -name my.cnf) In [mysqld]
relay-log = slave- relay-bin
It is not clear what this does. Add these two items.
Restart the mysql service
Log in to mysql and stop the synchronization command
Execute the command prepared above; Log in to the Slave server , connect to the Master server:
4. Test results from the master and slave servers
Create a database on the master server
Check the database just created on the slave server
You can find that the master-slave server configuration is complete.
================================================ ==================================================
Because the above is a mysql master-slave configuration for two new machines; there is no need to import the previous data from the master server to the slave server; then if the master server already has some data, you need to add the import from the master server Operation of data to slave server;
After configuring the master server to grant permissions to the slave server;
1. Execute the following command to lock the database to prevent data from being written;This command is a global read lock. After executing the command, all tables in all libraries will be locked as read-only. It is generally used for database online backup. At this time, the write operation of the database will be blocked and the read operation can proceed smoothly;
2. Exit the mysql command line, export the database to the root file and name it all.sql;
3. Use the scp command to transfer the database file all.sql to From the server;
4. Connect to the database again and enter the mysql command to view the master status and record the values of file and position;
5 .Unlock the data table;
Before configuring the slave server, import the data first;
1. Import the database of the master server;
2. The subsequent configuration is the same as the previous slave server configuration;
The above is the detailed content of Mysql master-slave synchronization configuration method. For more information, please follow other related articles on the PHP Chinese website!

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

Big data structure processing skills: Chunking: Break down the data set and process it in chunks to reduce memory consumption. Generator: Generate data items one by one without loading the entire data set, suitable for unlimited data sets. Streaming: Read files or query results line by line, suitable for large files or remote data. External storage: For very large data sets, store the data in a database or NoSQL.

Setting font size has become an important personalization requirement as mobile phones become an important tool in people's daily lives. In order to meet the needs of different users, this article will introduce how to improve the mobile phone use experience and adjust the font size of the mobile phone through simple operations. Why do you need to adjust the font size of your mobile phone - Adjusting the font size can make the text clearer and easier to read - Suitable for the reading needs of users of different ages - Convenient for users with poor vision to use the font size setting function of the mobile phone system - How to enter the system settings interface - In Find and enter the "Display" option in the settings interface - find the "Font Size" option and adjust it. Adjust the font size with a third-party application - download and install an application that supports font size adjustment - open the application and enter the relevant settings interface - according to the individual

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

Mobile phone film has become one of the indispensable accessories with the popularity of smartphones. To extend its service life, choose a suitable mobile phone film to protect the mobile phone screen. To help readers choose the most suitable mobile phone film for themselves, this article will introduce several key points and techniques for purchasing mobile phone film. Understand the materials and types of mobile phone films: PET film, TPU, etc. Mobile phone films are made of a variety of materials, including tempered glass. PET film is relatively soft, tempered glass film has good scratch resistance, and TPU has good shock-proof performance. It can be decided based on personal preference and needs when choosing. Consider the degree of screen protection. Different types of mobile phone films have different degrees of screen protection. PET film mainly plays an anti-scratch role, while tempered glass film has better drop resistance. You can choose to have better

How to insert data into MySQL table? Connect to the database: Use mysqli to establish a connection to the database. Prepare the SQL query: Write an INSERT statement to specify the columns and values to be inserted. Execute query: Use the query() method to execute the insertion query. If successful, a confirmation message will be output.

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

To use MySQL stored procedures in PHP: Use PDO or the MySQLi extension to connect to a MySQL database. Prepare the statement to call the stored procedure. Execute the stored procedure. Process the result set (if the stored procedure returns results). Close the database connection.
