MySQL main configuration

1.vim /etc/my.cnf

[mysqld]

datadir
=/var/lib/mysql
socket
=/var/lib/mysql/mysql.sock
user
=mysql
# Disabling symbolic
-links is recommended to prevent assorted security risks
symbolic
-links=0

server
-id=1
log_bin
=mysqlbin
relay_log
=relaylog

[mysqld_safe]
log
-error=/var/log/mysqld.log
pid
-file=/var/run/mysqld/mysqld.pid

2 .service mysqld restart

3. Enter Mysql

mysql> grant all on *.* to [email Protected]'192.168.146.%' identified by '123';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

Share pictures

4. Enter Slave server

5.vim /etc/my.cnf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

server-id=2
log_bin=mysqllog
relay_log=mysqlrelay

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

6. Enter from Mysql

mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> change master to master_host=‘192.168.146.6’, master_user=‘tom’,master_password=‘123’,master_log_file=‘mysqlbin.000003’,master_log_pos=315;
Query OK, 0 rows affected (0.39 sec)

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

mysql> show slave status \G;

  Share a picture

Configure the master, repeat the operation on the master server from step 6

[mysqld]

datadir
=/var/lib/mysql
socket
=/var/lib/mysql/mysql.sock
user
=mysql
# Disabling symbolic
-links is recommended to prevent assorted security risks
symbolic
-links=0

server
-id=1
log_bin
=mysqlbin
relay_log
=relaylog

[mysqld_safe]
log
-error=/var/log/mysqld.log
pid
-file=/var/run/mysqld/mysqld.pid

< pre class="brush:bash;gutter:true;">mysql> grant all on *.* to [email protected]’192.168.146.%’ identified by ‘123’;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

server-id=2
log_bin=mysqllog
relay_log=mysqlrelay

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> change master to master_host=‘192.168.146.6’, master_user=‘tom’,master_password=‘123’,master_log_file=‘mysqlbin.000003’,master_log_pos=315;
Query OK, 0 rows affected (0.39 sec)

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

mysql> show slave status \G;

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2957 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.