Mysql master-slave replication from the database cannot be started

Observe the registry (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MYSQL), the ImagePathkey length of the main database is like thisC:\MySql\mysql-8.0.17-winx64\bin\mysqld MySQL

I follow other tutorials to make it so that the C:\MySql\mysql-8.0.17\mysql-8.0.17-winx64\bin\mysqld --default-file=C:\MySql\mysql-8.0.17\mysql-8.0.17-winx64\my.ini mysqls1result cannot be started

Finally, the comparison was modified toC:\MySql\mysql-8.0.17\mysql-8.0.17-winx64\bin\mysqld mysqls1

Started successfully.

Additional commands are attached to
start, shut down, and remove the service mysqls1
net start mysqls1
net stop mysqls1
mysqld --remove mysqls1

Initialize the data directory and execute it in the bin directory.
mysqld --initialize --user=mysql --console

Register from the database service mysqls1
mysqld install mysqls1 --default-file="C:\MySql\mysql-8.0.17\mysql-8.0.17-winx64\my.ini"

Remove mysqls1 from database
mysqld --remove mysqls1

Set a new password under 8.0

am>alter user 'root'@'localhost' identified with mysql_native_password by '新密码'

am>flush privileges;

Create user
mysql> create user'root'@'%' identified by'password';
Query OK, 0 rows affected (2.35 sec)
Authorization
mysql> grant all privileges on . To'root'@'%';
Query OK, 0 rows affected (0.06 sec)
refresh
mysql> flush privileges;
Query OK, 0 rows affected (0.06 sec)

From database

stop slave;
change master to
master_host=‘localhost’,
master_user=‘wufan’,
master_password=‘qq1780636778’,
master_log_file=‘mysql-bin.000018’,
master_log_pos=155;
start slave;
show slave status;

Change the password after reinstalling the database
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
or
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码'';

mysql_native_password和caching_sha2_password两种方式 在my.ini配置项default_authentication_plugin=mysql_native_password

select user,host,plugin from mysql.user;

Master-slave database my.ini configuration

Primary database
port=3306
default_authentication_plugin=mysql_native_password #Unique
, different from the standby
server_id = 1 #Open
binary log
log-bin= mysql-bin #Database to
be synchronized
binlog-do-db=user_db #Database binlog that
does not need to be shielded
-ignore-db=mysql
binlog-ignore-db=information_schema
binlog-ignore-db=performance_schema
binlog_format=ROW

From the database
port=3307
[mysqld]
port=3307
default_authentication_plugin=mysql_native_password
server_id=2 #Open
binary log
log-bin= mysql-bin
binlog_format=ROW #The
database that needs to be synchronized
replicate_wild_do_table=user_db.% #The
database that does not need to be shielded
replicate_wild_ignore_table=mysql .%
replicate_wild_ignore_table=information_schema.%
replicate_wild_ignore_table=performance_schema.%

Registry key

C:\MySql\mysql-8.0.17\mysql-8.0.17-winx64\bin\mysqld mysqls1
is the mysql service directory + service name (you can find it in the service)

恢复数据库命令 mysql -u root -p < C:\MySql\mysql-8.0.17-winx64\sqlfile23.sql

Backup database
mysqldump -u username -p dbname [tbname …]> filename.sql The
above syntax parameters are described as follows:
username: indicates the user name;
dbname: indicates the name of the
database to be backed up ; tbname: indicates the data table in the database that needs to be backed up. You can specify multiple data tables. When this parameter is omitted, the entire database will be backed up; the
right arrow ">": used to tell mysqldump to write the definition and data of the backup data table into the backup file;
filename.sql: the name of the backup file, the absolute path can be added in front of the file name . Usually the database is backed up to a file with a .sql extension.

Guess you like

Origin blog.csdn.net/qq_34713855/article/details/109959745