centos7+mysql5.7二进制安装
发表于:2025-11-12 作者:千家信息网编辑
千家信息网最后更新 2025年11月12日,一、优化部分1、操作系统参数调优2、数据库参数调优3、防火墙设置等二、安装部分1、创建用户和组# groupadd mysql# useradd -g mysql mysql2、到安装目录,解压安装文
千家信息网最后更新 2025年11月12日centos7+mysql5.7二进制安装
一、优化部分
1、操作系统参数调优
2、数据库参数调优
3、防火墙设置等
二、安装部分
1、创建用户和组
# groupadd mysql# useradd -g mysql mysql
2、到安装目录,解压安装文件
#cd /data#tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz#mv mysql-5.7.19-linux-glibc2.12-x86_64 mysql
3、创建数据库安装目录、授权
#mkdir /data/mysql/data /data/mysql/log #chown -R mysql:mysql /data/mysql
4、验证权限
# ls -l mysql
total 52drwxr-xr-x 2 mysql mysql 4096 Aug 8 04:06 bin-rw-r--r-- 1 mysql mysql 17987 Jun 22 22:13 COPYINGdrwxr-xr-x 2 mysql mysql 4096 Aug 8 04:06 docsdrwxr-xr-x 3 mysql mysql 4096 Aug 8 04:06 includedrwxr-xr-x 5 mysql mysql 4096 Aug 8 04:06 libdrwxr-xr-x 4 mysql mysql 4096 Aug 8 04:06 man-rw-r--r-- 1 mysql mysql 2478 Jun 22 22:13 READMEdrwxr-xr-x 28 mysql mysql 4096 Aug 8 04:06 sharedrwxr-xr-x 2 mysql mysql 4096 Aug 8 04:06 support-files
5、编辑参数文件
vim /etc/my.cnf[client]port = 3306socket = /data/mysql/data/mysql.sock[mysqld]server_id=10port = 3306user = mysqlcharacter-set-server = utf8mb4default_storage_engine = innodblog_timestamps = SYSTEMsocket = /data/mysql/data/mysql.sockbasedir = /data/mysqldatadir = /data/mysql/datapid-file = /data/mysql/data/mysql.pidmax_connections = 1000max_connect_errors = 1000table_open_cache = 1024max_allowed_packet = 128Mopen_files_limit = 65535#####====================================[innodb]==============================innodb_buffer_pool_size = 1024Minnodb_file_per_table = 1innodb_write_io_threads = 4innodb_read_io_threads = 4innodb_purge_threads = 2innodb_flush_log_at_trx_commit = 1innodb_log_file_size = 512Minnodb_log_files_in_group = 2innodb_log_buffer_size = 16Minnodb_max_dirty_pages_pct = 80innodb_lock_wait_timeout = 30innodb_data_file_path=ibdata1:1024M:autoextendinnodb_undo_tablespaces=3#####====================================[log]==============================log_error = /data/mysql/log/mysql-error.log slow_query_log = 1long_query_time = 1 slow_query_log_file = /data/mysql/log/mysql-slow.logsql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
6、安装数据库
# yum -y install libaio# ./bin/mysqld --initialize --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data --innodb_undo_tablespaces=3 --explicit_defaults_for_timestamp
7、配置启动文件
cp support-files/mysql.server /etc/init.d/mysqldchkconfig --add mysqldchkconfig mysqld onservice mysqld start
8、配置环境变量
vi /etc/profile#for mysql mysql_home=/data/mysqlPATH=$PATH:$mysql_home/binsource /etc/profile
9、查看默认密码
grep -i password /mysql/log/mysql-error.log
10、初始化密码
mysql -uroot -p'xxxxx'SET PASSWORD=PASSWORD('root');flush privileges;11、数据库常规启停
#mysqladmin -uroot -proot shutdown#mysqld_safe --defaults-file=/etc/my.cnf ps -ef|grep mysql
12、安全配置
# mysql_secure_installation Securing the MySQL server deployment.Enter password for user root: VALIDATE PASSWORD PLUGIN can be used to test passwordsand improve security. It checks the strength of passwordand allows the users to set only those passwords which aresecure enough. Would you like to setup VALIDATE PASSWORD plugin?Press y|Y for Yes, any other key for No: yThere are three levels of password validation policy:LOW Length >= 8MEDIUM Length >= 8, numeric, mixed case, and special charactersSTRONG Length >= 8, numeric, mixed case, special characters and dictionary filePlease enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2Using existing password for root.Estimated strength of the password: 25 Change the password for root ? ((Press y|Y for Yes, any other key for No) : yNew password: Re-enter new password: Sorry, passwords do not match.New password: Re-enter new password: Sorry, passwords do not match.New password: Re-enter new password: Estimated strength of the password: 50 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y ... Failed! Error: Your password does not satisfy the current policy requirementsNew password: Re-enter new password: Estimated strength of the password: 100 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : yBy default, a MySQL installation has an anonymous user,allowing anyone to log into MySQL without having to havea user account created for them. This is intended only fortesting, and to make the installation go a bit smoother.You should remove them before moving into a productionenvironment.Remove anonymous users? (Press y|Y for Yes, any other key for No) : ySuccess.Normally, root should only be allowed to connect from'localhost'. This ensures that someone cannot guess atthe root password from the network.Disallow root login remotely? (Press y|Y for Yes, any other key for No) : ySuccess.By default, MySQL comes with a database named 'test' thatanyone can access. This is also intended only for testing,and should be removed before moving into a productionenvironment.Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y - Dropping test database...Success. - Removing privileges on test database...Success.Reloading the privilege tables will ensure that all changesmade so far will take effect immediately.Reload privilege tables now? (Press y|Y for Yes, any other key for No) : ySuccess.All done!
相关阅读:
Mysql在各个系统的安装教程
Mysql 5.7.19 免安装版配置方法教程详解(64位)
Mysql 5.7.19 免安装版遇到的坑(收藏)
MySQL 5.7.19安装目录下创建my.ini文件的方法
数据
数据库
文件
配置
参数
目录
密码
教程
方法
系统
部分
安全
操作系统
变量
常规
权限
环境
用户
防火墙
防火
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
暗黑破坏神4哪个服务器好用
软件开发源程序注释要求
蓝牙数据库
大旗网络安全科技馆
日照联想服务器代理测评
公益慈善管理专业数据库系统
停车场服务器内存不足
融媒体中心网络技术笔试
excel图片导入数据库
校园网络安全解决方案设计
电脑app编程软件开发
wcd数据库管理系统
省市区mysql数据库
云服务器存在哪些安全风险
江西常用软件开发报价
知语网络技术
sql 数据库版本706
确保网络安全不出一丝新闻
中兴服务器的三大供应来源
如何定时清理数据库指定表
是华品博睿网络技术有限公司
浪潮服务器查看cpu风扇
计算机软件开发助理
云服务器上装什么安全软件好
软件开发 个人收汇
服务器的安全保密协议
深圳高新科技园区互联网公司
网络技术基础知识教案
玉田企业网络技术创造辉煌
数据库查看工具 支持卡片