centos 7安装mysql 5.7

一、安装环境
操作系统:CentOS 7.2.1511
mysql版本: mysql-5.7.35-el7-x86_64.tar.gz

二、下载安装包
下载mysql 5.7 社区版安装包
下载地址:https://downloads.mysql.com/archives/community/
选择对应自己操作系统版本的安装包,本人选 择的是Redhat 7环境二进制tar安装包
在这里插入图片描述
下载好的安装包:
在这里插入图片描述
三、上传安装包到服务器,并解压安装包到/root目录

[root@node1 ~]# ls
anaconda-ks.cfg       mysql-5.7.35-el7-x86_64.tar.gz  公共  视频  文档  音乐
initial-setup-ks.cfg  optimize_system_conf.sh         模板  图片  下载  桌面
[root@node1 ~]#

四、安装步聚

[root@node1 mysql]# groupadd mysql
[root@node1 mysql]# useradd -r -g mysql -s /bin/false mysql
[root@node1 mysql]# cd /usr/local
[root@node1 local]# tar zxvf /root/mysql-5.7.35-el7-x86_64.tar.gz
[root@node1 local]# ln -s /usr/local/mysql-5.7.35-el7-x86_64/ mysql
[root@node1 local]# cd mysql
[root@node1 mysql]# mkdir mysql-files
[root@node1 mysql]# chown mysql:mysql mysql-files
[root@node1 mysql]# chmod 750 mysql-files
[root@node1 mysql]# bin/mysqld --initialize --user=mysql
[root@node1 mysql]# bin/mysql_ssl_rsa_setup
[root@node1 mysql]# bin/mysqld_safe --user=mysql &
[1] 5394
[root@node1 mysql]# 2021-11-26T03:44:38.023194Z mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', however fil                              e don't exists. Create writable for user 'mysql'.

[1]+  退出 1                bin/mysqld_safe --user=mysql
##此处报错,没有/var/log/mariadb/mariadb.log文件,无创建文件权限,下面创建相关文件
[root@node1 mysql]# mkdir /var/log/mariadb
[root@node1 mysql]# touch /var/log/mariadb/mariadb.log
[root@node1 mysql]# chown -R mysql:mysql /var/log/mariadb/
[root@node1 mysql]# bin/mysqld_safe --user=mysql &
[1] 6256
[root@node1 mysql]# 2021-11-26T04:28:16.571601Z mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
2021-11-26T04:28:16.621895Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2021-11-26T04:28:17.471845Z mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended

[1]+  完成                  bin/mysqld_safe --user=mysql
[root@node1 mysql]#

[root@node1 mysql]# cp support-files/mysql.server /etc/init.d/mysql.server
[root@node1 mysql]#

note: 注意保存初始化时的信息,里面有初始化密码
[root@node1 mysql]# bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data
2021-11-26T15:59:54.601968Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-11-26T15:59:55.024143Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-11-26T15:59:55.056686Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-11-26T15:59:55.125264Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: e5beac3d-4ed1-11ec-874b-000c294c4a24.
2021-11-26T15:59:55.126059Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed’ cannot be opened.
2021-11-26T15:59:55.278318Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2021-11-26T15:59:55.278332Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2021-11-26T15:59:55.278776Z 0 [Warning] CA certificate ca.pem is self signed.
2021-11-26T15:59:55.333011Z 1 [Note] A temporary password is generated for root@localhost: a=HEli+_<4#3
[root@node1 mysql]#

修改/etc/my.cnf

[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock

[mysqld_safe]
log-error=/var/log/mysql.log
pid-file=/usr/local/mysql/data/mariadb.pid


重置密码:


mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)

修改服务端为utf8编码,binlog格式为row在/etc/my.cnf中添加
[mysqld]
character-set-server=utf8
binlog_format=ROW
default-time-zone=’+08:00’

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值