mysql.txt 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. 1、rpm安装
  2. wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
  3. rpm -ivh mysql57-community-release-el7-9.noarch.rpm
  4. yum install mysql-community-server
  5. 安装如下:
  6. mysql-community-libs x86_64 5.7.17-1.el7 mysql57-community 2.1 M
  7. mysql-community-libs-compat x86_64 5.7.17-1.el7 mysql57-community 2.0 M
  8. mysql-community-server x86_64 5.7.17-1.el7 mysql57-community 162 M
  9. mysql-community-client x86_64 5.7.17-1.el7 mysql57-community 24 M
  10. mysql-community-common x86_64 5.7.17-1.el7 mysql57-community 271 k
  11. 修改配置文件 /etc/my.cnf
  12. 2、systemctl启动mysql
  13. systemctl start mysqld
  14. systemctl status mysqld
  15. 查看 /var/log/mysqld.log 启动日志
  16. 3、systemctl设置开机启动
  17. systemctl enable mysqld
  18. systemctl daemon-reload
  19. 3、修改mysql root密码
  20. grep 'temporary password' /var/log/mysqld.log
  21. ALTER USER 'root'@'localhost' IDENTIFIED BY 'mypasswd';
  22. 创建新用户并授权
  23. CREATE USER 'mysql_user'@'%' IDENTIFIED BY 'mypasswd';
  24. GRANT ALL ON *.* TO 'mysql_user'@'%';
  25. flush privileges;
  26. 配置文件:/etc/my.cnf
  27. 日志文件:/var/log/mysqld.log
  28. 服务启动脚本:/usr/lib/systemd/system/mysqld.service
  29. socket文件:/var/run/mysqld/mysqld.pid
  30. 主从配置:
  31. 1. 主服务器创建用于同步复制的用户
  32. GRANT REPLICATION SLAVE ON *.* to 'myusername'@'%';
  33. 2. 主服务器dump数据, 从服务器导入执行.
  34. 3. 重新设置主从同步;
  35. Master: flush tables with read lock;
  36. Master: show master status;
  37. Slave: stop slave;
  38. Slave: change master to master_host='host',master_user='user',master_password='password',master_log_file='binlog.000004',master_log_pos=1947;
  39. Slave: show slave status;
  40. Slave: start slave;
  41. Master: unlock tables;
  42. 查看binlog内容
  43. mysqlbinlog --no-defaults --base64-output=decode-rows -v binlog.000001