centos7+mysql5.7二进制安装
发表于:2026-11-03 作者:千家信息网编辑
千家信息网最后更新 2026年11月03日,一、优化部分1、操作系统参数调优2、数据库参数调优3、防火墙设置等二、安装部分1、创建用户和组# groupadd mysql# useradd -g mysql mysql2、到安装目录,解压安装文
千家信息网最后更新 2026年11月03日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安全错误
数据库的锁怎样保障安全
互联网科技公司排名
百单网互联网科技有限公司怎么样
科技类互联网
广州宏创互联网科技
广州互联网络科技有限公司
沃里互联网科技
人人互联网科技是培训
卓越科技互联网 招聘
互联网和高科技公司
现代互联网科技股
呼和浩特新华互联网科技学院
互联网保险科技创业
中国互联网公司排名锤子科技
互联网科技的全部知识
深圳艾果互联网通讯科技
世界互联网领先科技成果获奖
徐州市互联网科技有限公司
互联网科技资金流入
互联网科技品牌
山东亿川互联网科技有限责任公司
互联网科技巨头监管
关于新基建和互联网科技
互联网公司 科技公司
北京大学互联网科技怎么样
阿大互联网科技有限公司
互联网科技商业
半导体行业属于互联网高科技类吗
云鲸互联网络科技有限公司
互联网科技机房
盐城市攀科互联网科技有限公司