mysql常用操作
mysql创建用户
create user 'root'@'192.168.10.32';
ALTER USER 'root'@'192.168.10.32' IDENTIFIED WITH mysql_native_password BY 'root';
GRANT ALL ON *.* TO 'root'@'192.168.10.32';
flush privileges;
create user 'root'@'192.168.10.32'; //create user 'root'@'192.168.10.%';
5.6 update mysql.user set password=password('root') where host = '192.168.3.23' and user='root';
5.7 update mysql.user set authentication_string=password('root') where host = '192.168.3.23' and user='root';
5.7 ALTER USER 'root'@'192.168.10.32' IDENTIFIED WITH mysql_native_password BY 'root';
8.0 ALTER USER 'root'@'192.168.10.32' IDENTIFIED WITH mysql_native_password BY 'root'; //ALTER USER 'root'@'192.168.10.%' IDENTIFIED WITH mysql_native_password BY 'root';
GRANT ALL ON *.* TO 'root'@'192.168.10.32'; //GRANT ALL ON *.* TO 'root'@'192.168.10.%';
flush privileges;
mysql手动应用二进制日志
mysqlbinlog --no-defaults --start-position=1 D:\mysql812\mysql-8.0.12-winx64\data\binlog.000011 | mysql -uroot -proot --port 4445
mysql主从复制
mysqldump --port 3208 -h 127.0.0.1 --master-data=2 --lock-all-tables --routines --triggers --events -uroot -p --databases lhh > d:/bak2.sql
#mysqldump --port 3208 -h 127.0.0.1 --master-data=2 --lock-all-tables --routines --triggers --events --opt -d lhh -uroot -p > d:/bak3.sql #只备份结构
#mysqldump --port 3208 -h 127.0.0.1 --master-data=2 -uroot -p -t lhh > d:/bak5.sql #只备份数据
CHANGE MASTER TO
MASTER_HOST='127.0.0.1',
MASTER_USER='root',
MASTER_PASSWORD='root',
MASTER_LOG_FILE='mysql-bin.000013',
master_port=3208,
MASTER_LOG_POS=235;
start slave;
mysql误删除恢复(mysql崩溃数据一致性恢复)
binlog2sql恢复不一致数据