Mysql 5.7.40 部署安装

Mysql 5.7.40 部署安装

1.上传下载好的安装包

mysql-5.7.40-el7-x86_64.tar

2.安装Mysql

2.1解压安装包
tar -xf mysql-5.7.40-el7-x86_64.tar
tar -xvf mysql-5.7.40-el7-x86_64.tar.gz

将解压后的目录移动到/usr/local/下
mv mysql-5.7.40-el7-x86_64 /usr/local/mysql

创建数据目录

mkdir /data/mysqldata
2.2创建用户、组
groupadd mysql
useradd -g mysql mysql
2.3修改配置文件
vim /etc/my.cnf

[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysqldata
socket=/tmp/mysql.sock
log-error=/data/mysqldata/mysql.err
pid-file=/data/mysqldata/mysql.pid
#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true
2.4 初始化数据库
./mysqld --initialize --user=mysql --datadir=/data/mysqldata/ --basedir=/usr/local/mysql/

初始化后会在日志文件内输出信息

cat /data/mysqldata/mysql.err 

2023-04-20T09:37:58.848844Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-04-20T09:37:58.889050Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-04-20T09:37:58.941951Z 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: 094f19a7-df5f-11ed-b280-f4e97577bc78.
2023-04-20T09:37:58.942201Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-04-20T09:37:59.106516Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2023-04-20T09:37:59.106523Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2023-04-20T09:37:59.107046Z 0 [Warning] CA certificate ca.pem is self signed.
2023-04-20T09:37:59.129064Z 1 [Note] A temporary password is generated for root@localhost: hoC2ztV=EKDy

2.5添加软连接,重启mysql服务
ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
service mysql start

添加自启动

chkconfig --add mysql
2.6登录mysql 修改密码,访问权限
./mysql -h localhost -u root -p
hoC2ztV=EKDy

修改密码

set password=password('Mysql@2023');
flush privileges;

修改访问权限

use mysql;
update user set Host='%' where User='root';
flush privileges;
2.7测试
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

北山遇雪

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值