MySQL5.7中mysql.user表变化

问题描述
逻辑全备MySQL5.6.24后,导入到MySQL5.7.18. 经测试发现部分应用账号授权有问题,无法正常访问数据库。

错误信息
query failed: [1142] SELECT command denied to user ‘monitor’@’10...100’ for table ‘history_uint’ [select clock,ns,value from history_uint where itemid=103172 and clock<=1501496763 and clock>1501493163 order by clock desc limit 1]

排查过程
1.但这些用户权限在MySQL5.6中是正常的。由于是在同一台主机上进行的升级,排除了网络问题。
2.尝试给用户授权,出现如下错误
mysql> GRANT SELECT, INSERT, UPDATE, DELETE ON zabbix_pro.* TO ‘zabbix_pro’@’%’ ;
ERROR 1805 (HY000): Column count of mysql.user is wrong. Expected 45, found 43. The table is probably corrupted

解决方法
1.删掉从5.6中恢复过来的mysql.user表。
2.获取5.7中相同版本的表结构,重建mysql.user表。
3.用 pt-show-grants 获取MYSQL5.6的用户权限
4.在5.7中应用这些授权

通过比较发现
1.MySQL5.7中mysql.user表比MySQL5.6少了1个字段(Password)
2.MySQL5.7中mysql.user表比MySQL5.6多了3个字段(password_last_changed,password_lifetime,account_locked)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是 MySQL 5.7.34 的 my.cnf 配置文件详细配置,供参考: ``` [client] port=3306 socket=/var/run/mysqld/mysqld.sock [mysqld] user=mysql pid-file=/var/run/mysqld/mysqld.pid socket=/var/run/mysqld/mysqld.sock port=3306 basedir=/usr datadir=/var/lib/mysql tmpdir=/tmp lc-messages-dir=/usr/share/mysql skip-external-locking bind-address=0.0.0.0 # Default configuration for InnoDB innodb_file_per_table=1 innodb_buffer_pool_size=2G innodb_log_file_size=512M innodb_flush_log_at_trx_commit=1 innodb_lock_wait_timeout=50 innodb_flush_method=O_DIRECT # Log settings log_error=/var/log/mysql/error.log slow_query_log=1 slow_query_log_file=/var/log/mysql/mysql-slow.log long_query_time=2 # Security settings skip_name_resolve=1 secure-file-priv=/var/lib/mysql-files max_allowed_packet=256M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES # Performance tuning query_cache_type=1 query_cache_size=256M query_cache_limit=2M max_connections=1000 thread_cache_size=128 table_open_cache=2048 key_buffer_size=256M sort_buffer_size=2M read_buffer_size=2M read_rnd_buffer_size=2M join_buffer_size=2M tmp_table_size=256M max_heap_table_size=256M ``` 这份配置文件包含了一些常用的 MySQL 配置项,包括: - 客户端和服务器的端口和套接字设置 - 数据库文件和日志文件的路径 - InnoDB 存储引擎的配置项,包括文件大小、缓冲池大小等 - 日志和安全相关的配置项,包括错误日志、慢查询日志、安全文件目录等 - 性能相关的配置项,包括查询缓存、连接数、缓存大小等。 当然,这份配置文件并不是适用于所有情况的,您需要根据自己的实际需求进行调整。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值