linux CentOS 7 系统应该如何安装mysql 5.7.13

发布时间:2020-04-24 09:58:10 作者:三月
来源:亿速云 阅读:273

本文主要给大家介绍linux CentOS 7 系统应该如何安装mysql 5.7.13,其所涉及的东西,从理论知识来获悉,有很多书籍、文献可供大家参考,从现实意义角度出发,亿速云累计多年的实践经验可分享给大家。

1.安装环境:

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

Mysql版本号:mysql-5.7.13-linux-glibc2.5-x86_64.tar

各项配置路径:
安装文件下载目录:/data/software   (软件包所在位置)
Mysql目录安装位置:/usr/local/mysql
数据库保存位置:/data/mysql
日志保存位置:/data/log/mysql

 2.本人百度云盘分享,下载mysql
    https://pan.baidu.com/s/1nuEypO9

 3.安装主要步骤:

linux CentOS 7 系统应该如何安装mysql 5.7.13

# rpm -qa |grep -i mariadb
# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64

执行如下命名:

# mkdir -p /data/software
# mkdir -p /data/log/mysql 
# cd /data/software    #(上传安装包)

通过xftp或 rz命令 上传mysql安装包。

# cd /usr/local
# tar -xvf /data/software/mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz  
# mv mysql-5.7.13-linux-glibc2.5-x86_64 mysql          
# echo $?
0
# ll -h
总用量 0
drwxr-xr-x. 2 root root    6 11月  5 2016 bin
drwxr-xr-x. 2 root root    6 11月  5 2016 etc
drwxr-xr-x. 2 root root    6 11月  5 2016 games
drwxr-xr-x. 2 root root    6 11月  5 2016 include
drwxr-xr-x. 2 root root    6 11月  5 2016 lib
drwxr-xr-x. 2 root root    6 11月  5 2016 lib64
drwxr-xr-x. 2 root root    6 11月  5 2016 libexec
drwxr-xr-x. 9 7161 wheel 129 5月  25 2016 mysql-5.7.13-linux-glibc2.5-x86_64
drwxr-xr-x. 2 root root    6 11月  5 2016 sbin
drwxr-xr-x. 5 root root   49 8月  23 00:39 share
drwxr-xr-x. 2 root root    6 11月  5 2016 src
# mkdir -p /data/mysql      #创建数据仓库目录
# groupadd mysql    ---新建一个msyql组 
# useradd -r -s    ---新建msyql用户,禁止登录shell 
# cd /usr/local/mysql 
# chown -R mysql . 
# chgrp -R mysql .
# chown -R mysql /data/mysql
# cd /usr/local/mysql 
# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql #初始化mysql,记住初始mysql密码
# Touch mysql.error  
# bin/mysql_ssl_rsa_setup  --datadir=/data/mysql
# cd support-files/
# cp my-default.cnf /etc/my.cnf 
# cp mysql.server /etc/init.d/mysql
# vi /etc/init.d/mysql

将空白的basedir和datadir修改为以下配置:

basedir=/usr/local/mysql
datadir=/data/mysql

# vi /etc/my.cnf
修改为以下内容:

[client]
port = 3306
socket = /opt/mysql/mysql.sock
#character_set_server=utf8
default-character-set=utf8
[mysql]
no-auto-rehash
[mysqld]
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER
sql_mode=''
#default-character-set=utf8
socket = /opt/mysql/mysql.sock
basedir = /opt/mysql
max_allowed_packet = 32M
datadir = /data/mysql
explicit_defaults_for_timestamp = true
skip-ssl
secure-file-priv = NULL
lower_case_table_names = 1
back_log = 300
max_connections = 3000
max_connect_errors = 100
table_open_cache = 4096
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 128M
join_buffer_size = 128M
explicit_defaults_for_timestamp = true
thread_cache_size = 100
query_cache_size = 256M
query_cache_limit = 4M
ft_min_word_len = 8
thread_stack = 512k
transaction_isolation = REPEATABLE-READ
tmp_table_size = 128M
max_heap_table_size = 128M
#slow_query_log
slow_query_log_file = /data/log/mysql/slow.log
character-set-server=utf8
server_id =1
log-bin=mysqlbin-log
long_query_time = 3
slow_query_log = on
innodb_buffer_pool_size = 1287M                       
innodb_flush_log_at_trx_commit = 2                    
innodb_log_buffer_size = 32M                             
innodb_log_file_size = 512M  
innodb_log_files_in_group = 2 
innodb_max_dirty_pages_pct = 50 
innodb_file_per_table = 1 
binlog_format = ROW  
audit_json_file=on    #保证mysql重启后自动启动插件
plugin-load=AUDIT=libaudit_plugin.so    #防止删除了插件,重启后又会加载
audit_record_cmds='delete,update,create,drop,alter,grant,truncate'   #要记录哪些命令语句,因为默认记录所有操作; 
[mysqldump]
quick
max_allowed_packet = 32M
[mysqld_safe]
open-files-limit = 8192
log-error = /data/log/mysql/mysql_3306.err


以上为my.cnf中的内容

# cd /usr/local/mysql
# mkdir data
# chown -R mysql .
# chgrp -R mysql .
# bin/mysqld_safe --user=mysql &         (执行后,ps –ef|grep mysql,可以看到mysql的进程)
# bin/mysqld_safe  --skip-grant-tables --user=mysql &  (后台启动mysql,且忘记mysql密码时使用)
# bin/mysql --user=root -p

--输入第6步生成的临时密码

修改mysqlroot用户密码:

Mysql>set password for 'root'@'localhost' =password('redhat'); 
mysql>update mysql.user set authentication_string=password('redhat') where user='root';
mysql>grant all privileges on *.* to root@'%' identified by 'redhat'; mysql> flush privileges;
mysql> use mysql; mysql> select host,user from mysql.user;
 # vi /etc/profile # 添加mysql系统路径

添加:
export PATH=/usr/local/mysql/bin:$PATH

# source /etc/profile              #导入配置
# chmod 755 /etc/init.d/mysql   # 配置mysql自动启动 
# chkconfig --add mysql      #配置mysql自动启动 
# chkconfig --level 345 mysql on   #配置mysql自动启动

登录mysql:

# bin/mysql --user=root -p

至此mysql安装完成。

总结:

这种方式安装的mysql,

# systemctl stauts/start/stop mysql.service


等操作不起作用。


#service mysql status/stop

可以运行;

但是service mysql start 不能启动,需要用:# bin/mysqld_safe --user=mysql & 才能启动

看了以上linux CentOS 7 系统应该如何安装mysql 5.7.13介绍,希望能给大家在实际运用中带来一定的帮助。本文由于篇幅有限,难免会有不足和需要补充的地方,大家可以继续关注亿速云行业资讯板块,会定期给大家更新行业新闻和知识,如有需要更加专业的解答,可在官网联系我们的24小时售前售后,随时帮您解答问题的。

推荐阅读:
  1. Linux 下设置java环境和tomcat安装
  2. Linux自学笔记——日志服务之rsyslog

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

linux centos mysql 5.7.13

上一篇:java语言与平台有什么关系

下一篇:js实现音乐导航效果的代码分享

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》