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 install MySQL for linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article introduces the knowledge of "how to install MySQL in linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Linux installation MySQL steps

First, install Mysql

# yum install mysql-server

# chkconfig-- level 2345 mysqld on

# service mysqld start

# mysql_secure_installation

(press enter to set the password, etc.)

# make some installation settings according to the prompts, set the root password, delete the default account, delete the default database, disable root remote, etc.

II. Master setting

1. Modify the configuration file

# service mysqld stop

# vi / etc/my.cnf

# add the following settings under [mysqld], where MasterID is 1 Magi Slave and 2 (when multiple slaves, each slave will be set to a different ID)

Server-id=1

Log-bin=mysql-bin

# binlog-do-db=

# service mysqld start

Note:

A.log-bin means to enable binary logging and specify the log file name and path. Master-slave replication must use binary logs.

B.server-id is used to uniquely identify itself throughout the master-slave system, so the ID values of each master and slave server cannot be the same. If two Mysql have the same server-id, the former will be kicked out when the latter is connected successfully.

C.binlog-do-db sets the database to be synchronized. If this parameter is not added, all operations are synchronized.

two。 Configure master and slave (use when configuring master weight to prevent data loss)

Mysql > grant replication slave on *. * to'@ 'identified by''

Mysql > flush tables with read lock

Mysql > show master status

+-+

| | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | |

+-+

| | mysql-bin.000005 | 106 | |

+-+

Wait for Slave to set up slave.

Mysql > unlock tables

Note:

The a.grant statement gives replication permission to create a replication account. Set to connect to the master slave server corresponding to IP, or set to% allow all.

b. Before and after viewing the master status, you should lock the Master first, and then unlock it after the Slave is configured to prevent the Positioning value from changing.

-

3. Open port 3306

Step one:

# vi / etc/sysconfig/iptables

In the open file, insert:

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 3306-j ACCEPT

Step 2:

Restart the firewall

# service iptables restart

This is the end of the content of "how to install MySQL in linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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