Centos7 离线安装MySQL8

版本:
Centos: 7,
CPU: x86_64
MySQL:8.0

写在前面,如果需要MySQL区分大小写,则应该在第一次启动MySQL之前,找到mysqld(/usr/sbin/mysqld),使用如下命令启用一次:

mysqld --initialize --lower-case-table-names=1

然后,在/etc/my.cnf中添加同样的参数:

[mysqld]
lower-case-table-names=1
  1. 官网下载对应linux发行版本的RPM集成压缩包(bundle,700多M),包含MySQL所有依赖,记得区分处理器x86平台和ARM平台;
  2. 解压,按顺序安装rpm包,先从依赖包开始安装,如果缺少依赖,会提示你是哪一个,按照提示安装即可
rpm -ivh mysql-community-server-8.0.25-1.el7.x86_64.rpm
  1. 安装好后启动mysql
systemctl start mysqld

查看启动状态:

systemctl status mysqld
  1. 获取临时密码
grep 'temporary password' /var/log/mysqld.log

问题来了

  1. 登录**(坑1)**:
mysql -u root -p

输入临时密码无效

  1. 使用skip-grant-tables跳过密码登录
vim /etc/my.cnf
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock


skip-grant-tables


log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
  1. 重启mysql,重新登录,修改密码**(坑2)**
alter user 'root'@'localhost' identified by 'root';

提示:使用了skip-grant-tables,不能修改密码**(WTF)**

  1. 解决办法,先执行以下命令:
flush privileges;
再使用步骤3的命令修改密码,大功告成!
mysql> alter user 'root'@'localhost' identified by 'xxxxxxx';
Query OK, 0 rows affected (0.01 sec)
  1. 去掉my.ini中的skip-grant-tables参数,重启mysql,就可以愉快地玩耍了!

创建用户,添加权限

CREATE USER 'custom'@'%.example.com' IDENTIFIED BY 'password';
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP  ON customer.addresses  TO 'custom'@'%.example.com';
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值