mysql 1524_Debian/Ubuntu遇到MySQL错误ERROR 1524 (HY000):插件未加载的解决

如果你在Debian/Ubuntu操作系统上遇到MySQL错误:ERROR 1524 (HY000): Plugin ‘unix_socket’ is not loaded(插件'unix_socket'未加载),请采取以下方法解决。可先参考修复MariaDB出现Plugin ‘unix_socket’ is not loaded Error的方法。

背景

最近遇到了这个错误:ERROR 1524 (HY000): Plugin ‘unix_socket’ is not loaded,未在我的Debian 9服务器上加载成功,同时尝试以root用户身份向MariaDB数据库进行身份验证,经过查找后,我发现此错误的解决方法是使用mysqld_safe启动MySQL服务并重置root密码。

解决方法

第1步:停止mysql服务

请先停止MySQL服务:

$ sudo systemctl stop mysql

或者:

$ sudo /etc/init.d/mysql stop

第2步:使用mysqld_safe启动mysql

然后使用mysqld_safe和选项--skip-grant-tables启动mysql服务,并继续运行:

$ sudo mysqld_safe --skip-grant-tables &

[1] 8197

第3步:重置root用户密码

打开MySQL终端控制台,输入mysql -uroot命令:

$ mysql -uroot

Welcome to the MariaDB monitor.  Commands end with ; or g.

Your MariaDB connection id is 8

Server version: 10.3.14-MariaDB-1:10.3.14+maria~stretch mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]>

你应该没有密码验证到MySQL终端,现在切换到mysql数据库,运行USE mysql;命令:

MariaDB [(none)]> USE mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

然后进行重置root用户密码:

MariaDB [mysql]> update user set password=PASSWORD("NewRootPassword") where User='root';

Query OK, 0 rows affected (0.002 sec)

Rows matched: 1  Changed: 0  Warnings: 0

注:将NewRootPassword替换为root用户的新密码。

还将身份验证插件设置为本机:

MariaDB [mysql]> UPDATE USER SET plugin="mysql_native_password";

Query OK, 2 rows affected (0.001 sec)

Rows matched: 2  Changed: 2  Warnings: 0

最后关闭数据库会话:

MariaDB [mysql]> quit;

Bye

第4步:重置root用户密码

以标准方式重新启动mysql服务,但首先要停止服务:

$ sudo systemctl stop mysql

或者:

$ /etc/init.d/mysql stop

确保没有其他进程正在运行:

ps aux | grep mysql

启动mysql:

sudo systemctl start mysql

以root用户身份测试访问权限:

$ mysql -u root -p

Enter password:

Welcome to the MariaDB monitor.  Commands end with ; or g.

Your MariaDB connection id is 8

Server version: 10.3.14-MariaDB-1:10.3.14+maria~stretch mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> QUIT

Bye

注:操作完以上步骤后,错误就能得到解决了。

相关主题

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
错误代码2002 (HY000): 无法通过套接字 '/tmp/mysql' 连接到本地服务器。 这个错误通常在MySQL数据库服务器无法通过指定的套接字连接到本地服务器时发生。套接字是一种用于在不同进程之间传输数据的通信机制。 造成这个错误的原因可能有以下几种: 1. MySQL服务器启动:确保MySQL服务器正在运行。可以通过在终端中运行"sudo service mysql start"(Ubuntu/Debian)或"sudo systemctl start mysql"(Fedora/CentOS)来启动MySQL服务器。 2. MySQL服务器配置错误:检查MySQL服务器配置文件(通常位于/etc/mysql/my.cnf或/etc/my.cnf),确保其中指定的套接字路径与实际路径一致。如果路径不正确,可以通过编辑配置文件来更正。 3. MySQL套接字文件丢失或损坏:检查指定套接字路径下是否存在该套接字文件。如果套接字文件不存在或损坏,可以尝试重启MySQL服务器来重新创建套接字文件。 4. 权限问题:确保MySQL服务器启动的用户对指定的套接字文件有读写权限。可以使用chmod命令来更改套接字文件的权限。 5. 其它进程占用套接字:查看系统中是否有其它进程占用了指定的套接字文件。可以使用lsof命令来列出正在使用指定套接字文件的进程,然后结束或重启相应的进程。 总之,解决这个错误需要仔细检查MySQL服务器的配置和状态,并确保套接字文件的存在和权限设置正确。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值