MySQL detailed installation and configuration

MySQL detailed installation and configuration

mysql master-slave configuration

Preparation

  • Installation package

Download required packages for binary installation

Link: https://pan.baidu.com/s/1azoIIZqVw948xLnew2TEJQ
Extraction code: g7pl

image-20220726103852829

  • examine

Execute rpm -ea | grep MySQLto check whether the old version of MySQL is installed on the server

Use the command rpm -e --node's {-file-name} to delete MySQL. There may be dependencies when removing. Pay attention to a certain order.

img

departure

1. Copy the mysql installation package to linux.

image-20220726103852829

2. Install mysql

rpm -Uvh *.rpm --nodeps --force;

3. Modify the configuration

After the installation is complete, modify my.cnfthe path:/etc/my.cnf

The file has been provided~

#推荐配置:在my.cnf文件最下面加上如下配置
lower_case_table_names = 1
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION


max_connect_errors = 6000
interactive_timeout=7200
back_log=500
max_connections=3000
max_user_connections=300
skip-name-resolve
key_buffer_size=20480M
query_cache_size=512M
query_cache_type=1
read_buffer_size=32M
sort_buffer_size=32M
join_buffer_size =512M
read_rnd_buffer_size=32M
tmp_table_size=128M
thread_cache_size=128
max_allowed_packet=32M
binlog_cache_size = 4M

4. Start MySQL

Start: # service mysqld start

# 停止
service mysqld stop
#重启
service mysqld restart

5. View the temporary password

grep 'temporary password' /var/log/mysqld.log

image-20220726105239758

6. Log in to the mysql database

mysql -u root -p 
#修改root密码
set password for root@localhost=password('YZ@gtjy2022');
#退出mysql登录
exit
#mysql数据库默认是有密码复杂度验证的,如果不需要可以去掉:
#关闭密码复杂度验证
set global validate_password_policy=0;
#新密码长度大于等于1
set global validate_password_length=1;

7. Authorize the root user for remote access

#授权
grant all privileges on *.* to 'root'@'%' identified by 'YZ@gtjy2022';
#刷新操作
flush privileges;  
#退出mysql然后重启mysql
exit
service mysqld restart;

8. Connect navicat

image-20220726110549551

9. Others

#查看防火墙:
systemctl status firewalld.service;
#打开防火墙:
systemctl start firewalld.service;
#关闭防火墙:
systemctl stop firewalld.service;    
#永久禁止防火墙:
systemctl disable firewalld.service;
#开启状态:active(running)
#关闭状态:disavtive(dead)

Guess you like

Origin blog.csdn.net/Sunshine_Mr_Sun/article/details/126076450