Mysql5.7的安装与配置文件优化

1.安装mysql软件与它所需要的依赖包
在这里插入图片描述
2.初始优化mysql软件
sed -i ‘/^[mysqld] /a\innodb_buffer_pool_size=1G’ /etc/my.cnf #设置mysql虚拟内存为1G
sed -i ‘/^[mysqld]/a\max_connections=4000’ /etc/my.cnf #设置mysql最大连接请求数量为4000
sed -i ‘/^[mysqld]/a\ssl=off’ /etc/my.cnf #MySQL服务器端开启安全的加密通信
sed -i ‘/^[mysqld]/a\event_scheduler=ON’ /etc/my.cnf #开启mysql事件的状态
sed -i ‘/^[mysqld]/a\lower_case_table_names=1’ /etc/my.cnf #不区分大小写
sed -i ‘/^[mysqld]/a\max_allowed_packet=100M’ /etc/my.cnf #限制server接受的数据包的大小
sed -i ‘/^[mysqld]/a\sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION’ /etc/my.cnf #设置mysql 环境变量sql_mode,定义了mysql应该支持的sql语法,数据校验
sed -i ‘/^[mysqld]/a\skip_grant_tables’ /etc/my.cnf #初始化数据库
3. 重启数据库设置密码后删除 skip_grant_tables
systemctl enable mysqld && systemctl restart mysqld
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_43546282/article/details/83537450