侧边栏壁纸
博主昵称
WX

  • 累计撰写 13 篇文章
  • 累计收到 1 条评论

centos7配置部署mysql5.7

W●X
2021-06-02 / 0 评论 / 38 阅读 / 正在检测是否收录...

https://blog.csdn.net/u012052268/article/details/103923056
https://www.bbsmax.com/A/mo5kkgeM5w/
https://www.cnblogs.com/louis-liu-oneself/p/13504270.html
https://www.cnblogs.com/dengshihuang/p/8029092.html //参考C7

准备环境:

  1. 卸载之前mysql版本
  2. -qa | grep mysql //检查当前是否安装mysql

rpm -e 已经存在的MySQL全名

  1. 安装依赖包
  2. install -y gcc-c++ bison-devel ncurses-devel bison perl perl-devel perl perl-devel libaio

3.下载mysql
wget https://repo.huaweicloud.com/mysql/Downloads/MySQL-5.7/mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
4.解压mysql
tar zxvf mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz /usr/local/mysql
cp my-default.cnf /etc/my.cnf //拷贝配置文件并修改文件参考第10步骤
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld //拷贝启动脚本
mkdir /usr/local/mysql/data //创建MySQL数据data目录
5.添加用户组赋予权限
groupadd mysql
useradd -r -g mysql mysql
passwd mysql
chown -R mysql:mysql /usr/local/mysql/
chown -R mysql /usr/local/mysql/data
chown -R root /usr/local/mysql
cd /usr/local/mysql/bin

  1. 初始化数据库配置(注意会生成随机密码)
    ./mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ --initialize

7.启动数据库

mysql -hlocalhost -uroot -p

--如果出现:-bash: mysql: command not found
--就执行: # ln -s /usr/local/mysql/bin/mysql /usr/bin --没有出现就不用执行

/etc/init.d/mysql start

service mysqld restart

  1. 配置mysql自动启动

chmod 755 /etc/init.d/mysql

chkconfig --add mysql

chkconfig --level 345 mysql on

  1. 更改配置使其能远程连接
    --修改密码

mysql> set password=password('root');
--设置root账户的host地址(修改了才可以远程连接)
mysql>grant all privileges on . to 'root'@'%' identified by 'root';
mysql>flush privileges;

10.配置文件
[client]
port = 3306
socket = /home/mysql/mysql_data/mysql-5.7-01/mysql.sock
default-character-set = utf8
[mysqld]
port = 3306
socket = /home/mysql/mysql_data/mysql-5.7-01/mysql.sock
basedir = /home/mysql/mysql_client/mysql-5.7-01
datadir = /home/mysql/mysql_data/mysql-5.7-01
pid-file = /home/mysql/mysql_data/mysql-5.7-01/mysql/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 1
init-connect = 'SET NAMES utf8'
character-set-server = utf8
back_log = 300
max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size = 8
query_cache_type = 1
query_cache_size = 8M
query_cache_limit = 2M
ft_min_word_len = 4
log_bin = /home/mysql/mysql_logs/mysql-5.7-01/mysql-bin
binlog_format = mixed
expire_logs_days = 30
log_error = /home/mysql/mysql_logs/mysql-5.7-01/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /home/mysql/mysql_logs/mysql-5.7-01/mysql-slow.log
performance_schema = 0
explicit_defaults_for_timestamp
skip-external-locking
default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
interactive_timeout = 28800
wait_timeout = 28800
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M

write_buffer = 4M

0

评论 (0)

取消