CentOS-7 MySQL 5.7.20安装

1.检查系统是否安装了mariadb

rpm -qa | grep mariadb

发现已经安装,卸载

rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64

2.创建mysql用户组和mysql用户

3.拷贝文件mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz到opt目录

   tar -zxvf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz -C /usr/local/

  文件名称修改mysql

   mv mysql-5.7.20-linux-glibc2.12-x86_64 mysql

4.修改权限

5.执行命令

bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

此时要记住密码

6.启动mysql,并查看启动是否成功

bin/mysqld_safe --user=mysql &

7.通过初始密码登录MySQL,并修改密码,第一个密码是上面产生的密码

bin/mysql_ssl_rsa_setup  --datadir=/usr/local/mysql/data/mysql

bin/mysqladmin -uroot -p password

8.关闭MySQL服务,并查看是否关闭成功

bin/mysqladmin -uroot -p shutdown

9.设置开机自启

cp support-files/mysql.server /etc/rc.d/init.d/mysqld

chmod +x /etc/rc.d/init.d/mysqld

chkconfig --add mysqld

chkconfig --list mysqld

10.关闭mysql,配置全局变量

vi /etc/profile
在profile文件底部添加如下两行配置,保存后退出

PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH

export PATH

source /etc/profile

编辑profile

11.设置远程登录权限

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root123456' WITH GRANT OPTION;

设置防火墙

netstat -nupl|grep 3306

firewall-cmd --permanent --add-port=3306/tcp

firewall-cmd --reload

此时上传配置文件到/usr/loacal/mysql/support-files my-default.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
# 一般配置选项
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
socket = /tmp/mysql.sock
character-set-server=utf8
back_log = 300
max_connections = 3000
max_connect_errors = 50
table_open_cache = 4096
max_allowed_packet = 32M
#binlog_cache_size = 4M
max_heap_table_size = 128M
read_rnd_buffer_size = 16M
sort_buffer_size = 16M
join_buffer_size = 16M
thread_cache_size = 16
query_cache_size = 128M
query_cache_limit = 4M
ft_min_word_len = 8
thread_stack = 512K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 128M
#log-bin=mysql-bin
long_query_time = 6
server_id=1
innodb_buffer_pool_size = 1G
innodb_thread_concurrency = 16
innodb_log_buffer_size = 16M
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = on
[mysqldump]
quick
max_allowed_packet = 32M
[mysql]
no-auto-rehash
default-character-set=utf8
safe-updates
[myisamchk]
key_buffer = 16M
sort_buffer_size = 16M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192
[client]
/bin/bash: Q: command not found

再执行cp -a /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值