分类: 数据库

Could not increase number of max_open_files to more than 1024

MySQL 启动报错: Could not increase number of max_open_files to more than 1024 这意味着在某个地方达到了限制。让我们通过编辑任何配置的限制来解决此问题。请查看以下文件: /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf /etc/systemd/system/mysqld.service.d/limits.conf /usr/lib/…

阅读全文 »

MySQL 8 忘记密码的解决办法

mysql 以前版本重置密码的方式已经不适合于mysql 8,正确的步骤如下: 1. 在my.cnf添加skip-grant-tables 2. 重启mysql,直接敲mysql进入 3. 清空root密码 # update user set authentication_string=” where user=’root’; 4. my.cnf注释掉skip-grant-tables 5. 重启mysql 6. 敲mysql进入设置密码 # ALTER user ‘root’@’localh…

阅读全文 »

CentOS 7 安装 MySQL 8

安装mysql 8 yum源 # rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm 禁用所有的mysql repo 库 # sed -i ‘s/enabled=1/enabled=0/’ /etc/yum.repos.d/mysql-community.repo 安装mysql 8 # yum –enablerepo=mysql80-community install mysql-communi…

阅读全文 »

The server requested authentication method unknown to the client

php-mysqlnd连接mysql 8.0报错:The server requested authentication method unknown to the client,出现这个问题的原因是因 mysql8.0 引入了新特性 caching_sha2_password,而老版本的php-mysqlnd用的是mysql_native_password加密插件,解决方法如下: 1. 用如下语句查看MySQL当前加密方式 select host,user,plugin from user; …

阅读全文 »

MySQL 8.0 设置初始密码

安装好mysql 8.0后,查看初始密码: sudo grep ‘temporary password’ /var/log/mysqld.log 本地MySQL客户端登录:mysql -uroot -p ,输入默认密码进去,如果不修改默认密码,操作执行命令会报错如下: You must reset your password using ALTER USER statement before executing this statement. 修改密码 mysql> ALTER USER …

阅读全文 »

MySQL 8.0用户和角色管理

MySQL 8.0 正式版目前已发布,MySQL 8.0 增加了很多新的功能,具体可参考「MySQL 8.0 正式版 8.0.11 发布!」一文。 MySQL 8.0 在用户管理方面增加了角色管理,默认的密码加密方式也做了调整,由之前的 SHA1 改为了 SHA2。同时加上 MySQL 5.7 的禁用用户和用户过期的功能,MySQL 在用户管理方面的功能和安全性都较之前版本大大的增强了。 在本教程中,我们将介绍 MySQL 下用户管理上的一些新特性和如何使用角色来简化权限管理。 注:本教程大部分…

阅读全文 »

mysqldump: Got error: 1168: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn’t exist when using LOCK TABLES

用mysqldump命令备份数据库报如下错误 mysqldump: Got error: 1168: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn’t exist when using LOCK TABLES 解决办法: 备份添加–single-transaction参数 # mysqldump -uroot -p –single-transac…

阅读全文 »

如何修复损坏的MySQL数据表

断电或非正常关机而导致MySQL数据库表出现错误是非常常见的问题。有两种方法,一种方法使用mysql的check table和repair table的sql语句,另一种方法是使用MySQL提供的多个myisamchk, isamchk数据检测恢复工具。前者使用起来比较简便,推荐使用。 1. check table 和 repair table 登陆mysql 终端: mysql -uxxxxx -p dbname mysql> check table tabTest; 如果出现的结果说S…

阅读全文 »

mysql 复制状态参数Seconds_Behind_Master

MySQL 本身通过 show slave status 提供了 Seconds_Behind_Master ,用于衡量主备之间的复制延迟,但是 今天碰到了一个场景,发现 Seconds_Behind_Master 为 0 , 备库的 show slave status 显示 IO/SQL 线程都是正常的 , MySQL 的主库上的变更却长时间无法同步到备库上。如果没有人为干预,直到一个小时以后, MySQL 才会自动重连主库,继续复制主库的变更。 影响范围: MySQL , Percona ,…

阅读全文 »