Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure mysql in Ubuntu

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to configure mysql in Ubuntu. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. Set up a special user on master for replication: grant replication slave on *. * to 'replicationuser'@'192.168.51.165' identified by' 123456'

two。 Set the MasterMachine my.cnf:

Execute sudo vim etc/Ubuntu mysql/my.cnf to add the following content in the [Ubuntu mysqld] area: server-id = 1 log_bin = / var/log/Ubuntu mysql/Ubuntu mysql-bin.log # Open binary log binlog_do_db = testdb # databases that need to be synchronized, optional binlog_ignore_db = Ubuntu mysql,information_schema #

Do not need to synchronize the database, optional restart master server sudo / etc/init.d/Ubuntu mysql restart

3. Set the my.cnf of the slave machine:

Execute sudo vim etc/Ubuntu mysql/my.cnf to add the following in the [Ubuntu mysqld] area: server-id = 2 restart slave server sudo / etc/init.d/Ubuntu mysql restart

4. Refresh all table and block write statements on the primary server: flush tables with read lock; then read the binary filename and branch on the primary server: show master status; records the values of File and Position.

And back up the data on master to slave for initialization. (flush tables with read lock is to ensure that there are no database operations), (as long as the values of File and Position are recorded, step 6 can be performed to release the lock: Ubuntu mysql > unlock table;)

Scp-r. / * root@192.168.47.175:/var/lib/Ubuntu mysql change the root password sudo su-passwd with root*** permission

5. Log in to slave's Ubuntu mysql and replace the option with the real value of the system:

Ubuntu mysql > CHANGE MASTER TO MASTER_HOST='192.168.51.162',MASTER_USER='replicationuser', MASTER_PASSWORD='123456',MASTER_LOG_FILE='Ubuntu mysql-bin.000001',MASTER_LOG_POS=1279702;. Here master_log_file and master_log_pos are the results of the previous show master status.

6. Log in to master and release the lock: Ubuntu mysql > unlock table

7. Switch to the slave machine and start the slave thread: Ubuntu mysql > start slave; thus completing the configuration of the master/slave. * * you can use show processlist "G; to check the status of master and slave respectively. Master: 48 send binlog to slave and wait for update.

* * 5. Row * * Id: 48 User: replicationuser Host: 192.168.51.165 User 43746 db: NULL Command: Binlog Dump Time: 767 State: Has sent all binlog to slave; waiting for binlog to be updated Info: NULL

Slave:12 waits for master to send an update. 13 wait for data to be written by its own I "O thread

* * 3. Row * * Id: 12 User: system user Host: db: NULL Command: Connect Time: 470 State: Waiting for master to send event Info: NULL * * 4. Row * * Id: 13 User: system user Host: db: NULL Command: Connect Time: 359 State: Has read all relay log Waiting for the slave I/O thread to update it Info: NULL

If show processlist\ G; can see the above message, it means that the slave machine has been established successfully. Data changes made on the master will be immediately displayed on the slave machine.

The above is how to configure mysql in Ubuntu. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report