<small id='1v9eY'></small><noframes id='1v9eY'>

      <i id='1v9eY'><tr id='1v9eY'><dt id='1v9eY'><q id='1v9eY'><span id='1v9eY'><b id='1v9eY'><form id='1v9eY'><ins id='1v9eY'></ins><ul id='1v9eY'></ul><sub id='1v9eY'></sub></form><legend id='1v9eY'></legend><bdo id='1v9eY'><pre id='1v9eY'><center id='1v9eY'></center></pre></bdo></b><th id='1v9eY'></th></span></q></dt></tr></i><div id='1v9eY'><tfoot id='1v9eY'></tfoot><dl id='1v9eY'><fieldset id='1v9eY'></fieldset></dl></div>
      <tfoot id='1v9eY'></tfoot>

        <bdo id='1v9eY'></bdo><ul id='1v9eY'></ul>

      <legend id='1v9eY'><style id='1v9eY'><dir id='1v9eY'><q id='1v9eY'></q></dir></style></legend>
    1. 错误 1698 (28000):拒绝用户“root"@“localhost&qu

      时间:2023-08-17

        <small id='3KltI'></small><noframes id='3KltI'>

          <tbody id='3KltI'></tbody>

              <tfoot id='3KltI'></tfoot>
              • <bdo id='3KltI'></bdo><ul id='3KltI'></ul>

                <legend id='3KltI'><style id='3KltI'><dir id='3KltI'><q id='3KltI'></q></dir></style></legend>
                <i id='3KltI'><tr id='3KltI'><dt id='3KltI'><q id='3KltI'><span id='3KltI'><b id='3KltI'><form id='3KltI'><ins id='3KltI'></ins><ul id='3KltI'></ul><sub id='3KltI'></sub></form><legend id='3KltI'></legend><bdo id='3KltI'><pre id='3KltI'><center id='3KltI'></center></pre></bdo></b><th id='3KltI'></th></span></q></dt></tr></i><div id='3KltI'><tfoot id='3KltI'></tfoot><dl id='3KltI'><fieldset id='3KltI'></fieldset></dl></div>
              • 本文介绍了错误 1698 (28000):拒绝用户“root"@“localhost"的访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在设置一个新服务器,但一直遇到这个问题.

                I'm setting up a new server and keep running into this problem.

                当我尝试以 root 用户登录 MySQL 数据库时,出现错误:

                When I try to log into the MySQL database with the root user, I get the error:

                ERROR 1698 (28000): 用户 'root'@'localhost' 的访问被拒绝

                ERROR 1698 (28000): Access denied for user 'root'@'localhost'

                我是否通过终端 (SSH)、phpMyAdmin 或MySQL 客户端,例如 Navicat.他们都失败了.

                It doesn't matter if I connect through the terminal (SSH), through phpMyAdmin or a MySQL client, e.g., Navicat. They all fail.

                我查看了 mysql.user 表并得到以下信息:

                I looked in the mysql.user table and get the following:

                +------------------+-------------------+
                | user             | host              |
                +------------------+-------------------+
                | root             | %                 |
                | root             | 127.0.0.1         |
                | amavisd          | localhost         |
                | debian-sys-maint | localhost         |
                | iredadmin        | localhost         |
                | iredapd          | localhost         |
                | mysql.sys        | localhost         |
                | phpmyadmin       | localhost         |
                | root             | localhost         |
                | roundcube        | localhost         |
                | vmail            | localhost         |
                | vmailadmin       | localhost         |
                | amavisd          | test4.folkmann.it |
                | iredadmin        | test4.folkmann.it |
                | iredapd          | test4.folkmann.it |
                | roundcube        | test4.folkmann.it |
                | vmail            | test4.folkmann.it |
                | vmailadmin       | test4.folkmann.it |
                +------------------+-------------------+
                

                如您所见,用户 root 应该具有访问权限.

                As you can see, user root should have access.

                服务器非常简单,因为我已经尝试解决这个问题有一段时间了.

                The Server is quite simple, as I have tried to troubleshoot this for a while now.

                它正在运行 Ubuntu 16.04.1 LTS (Xenial Xerus) 使用 Apache、MySQL 和 PHP,以便它可以托管网站,以及 iRedMail 0.9.5-1,以便它可以托管邮件.

                It's running Ubuntu 16.04.1 LTS (Xenial Xerus) with Apache, MySQL and PHP, so that it can host websites, and iRedMail 0.9.5-1, so that it can host mail.

                在我安装 iRedMail 之前登录 MySQL 数据库工作正常.我也试过只安装 iRedMail,但是 root 也不起作用.

                Log into the MySQL database works fine before I installed iRedMail. I also tried just installing iRedMail, but then root also doesn't work.

                如何修复我的 MySQL 登录问题,或者如何通过现有的 MySQL 安装安装 iRedMail?是的,我尝试了安装技巧,但我不能在配置文件中找到这些变量.

                How can I fix my MySQL login problem or how can I install iRedMail over an existing MySQL install? And yes, I tried the Installation Tips and I can't find those variables in the configuration files.

                推荐答案

                某些系统如 Ubuntu、MySQL 正在使用 UNIX auth_socket 插件 默认.

                Some systems like Ubuntu, MySQL is using the UNIX auth_socket plugin by default.

                基本上这意味着:db_users 使用它,将被验证";通过系统用户凭据.您可以通过执行以下操作来查看您的 root 用户是否是这样设置的:

                Basically it means that: db_users using it, will be "authenticated" by the system user credentials. You can see if your root user is set up like this by doing the following:

                sudo mysql -u root # I had to use "sudo" since it was a new installation
                
                mysql> USE mysql;
                mysql> SELECT User, Host, plugin FROM mysql.user;
                
                +------------------+-----------------------+
                | User             | plugin                |
                +------------------+-----------------------+
                | root             | auth_socket           |
                | mysql.sys        | mysql_native_password |
                | debian-sys-maint | mysql_native_password |
                +------------------+-----------------------+
                

                正如您在查询中看到的,root 用户正在使用 auth_socket 插件.

                As you can see in the query, the root user is using the auth_socket plugin.

                有两种方法可以解决这个问题:

                There are two ways to solve this:

                1. 您可以设置root用户使用mysql_native_password插件
                2. 你可以创建一个新的db_usersystem_user(推荐)
                1. You can set the root user to use the mysql_native_password plugin
                2. You can create a new db_user with you system_user (recommended)

                选项 1:

                sudo mysql -u root # I had to use "sudo" since it was new installation
                
                mysql> USE mysql;
                mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
                mysql> FLUSH PRIVILEGES;
                mysql> exit;
                
                sudo service mysql restart
                

                选项 2:(将 YOUR_SYSTEM_USER 替换为您拥有的用户名)

                Option 2: (replace YOUR_SYSTEM_USER with the username you have)

                sudo mysql -u root # I had to use "sudo" since is new installation
                
                mysql> USE mysql;
                mysql> CREATE USER 'YOUR_SYSTEM_USER'@'localhost' IDENTIFIED BY 'YOUR_PASSWD';
                mysql> GRANT ALL PRIVILEGES ON *.* TO 'YOUR_SYSTEM_USER'@'localhost';
                mysql> UPDATE user SET plugin='auth_socket' WHERE User='YOUR_SYSTEM_USER';
                mysql> FLUSH PRIVILEGES;
                mysql> exit;
                
                sudo service mysql restart
                

                请记住,如果您使用选项 #2,则必须以系统用户名 (mysql -u YOUR_SYSTEM_USER) 连接到 MySQL.

                Remember that if you use option #2 you'll have to connect to MySQL as your system username (mysql -u YOUR_SYSTEM_USER).

                注意:在某些系统上(例如,Debian 9 (Stretch)) 'auth_socket' 插件被称为 'unix_socket',所以对应的SQL命令应该是:UPDATE user SET plugin='unix_socket' WHERE User='YOUR_SYSTEM_USER';

                Note: On some systems (e.g., Debian 9 (Stretch)) the 'auth_socket' plugin is called 'unix_socket', so the corresponding SQL command should be: UPDATE user SET plugin='unix_socket' WHERE User='YOUR_SYSTEM_USER';

                从@andy 的评论看来,MySQL 8.x.x 更新/替换了 caching_sha2_passwordauth_socket.我没有使用 MySQL 8.x.x 的系统设置来测试这个.但是,上述步骤应该可以帮助您理解问题.回复如下:

                From @andy's comment it seems that MySQL 8.x.x updated/replaced the auth_socket for caching_sha2_password. I don't have a system setup with MySQL 8.x.x to test this. However, the steps above should help you to understand the issue. Here's the reply:

                MySQL 8.0.4 的一个变化是新的默认身份验证插件是caching_sha2_password".新的YOUR_SYSTEM_USER"将拥有此身份验证插件,您现在可以使用mysql -u YOUR_SYSTEM_USER -p"从 Bash shell 登录.并在提示中提供该用户的密码.不需要UPDATE user SET plugin";步骤.

                对于 8.0.4 默认身份验证插件更新,请参阅 https://mysqlserverteam.com/mysql-8-0-4-new-default-authentication-plugin-caching_sha2_password/

                这篇关于错误 1698 (28000):拒绝用户“root"@“localhost"的访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何在mysql选择查询中获取两个日期之间的日期列 下一篇:如何在 MySQL 中找到包含特定列名的所有表?

                相关文章

                最新文章

                  <tfoot id='tLarw'></tfoot>
                1. <i id='tLarw'><tr id='tLarw'><dt id='tLarw'><q id='tLarw'><span id='tLarw'><b id='tLarw'><form id='tLarw'><ins id='tLarw'></ins><ul id='tLarw'></ul><sub id='tLarw'></sub></form><legend id='tLarw'></legend><bdo id='tLarw'><pre id='tLarw'><center id='tLarw'></center></pre></bdo></b><th id='tLarw'></th></span></q></dt></tr></i><div id='tLarw'><tfoot id='tLarw'></tfoot><dl id='tLarw'><fieldset id='tLarw'></fieldset></dl></div>
                    <bdo id='tLarw'></bdo><ul id='tLarw'></ul>

                  <small id='tLarw'></small><noframes id='tLarw'>

                  1. <legend id='tLarw'><style id='tLarw'><dir id='tLarw'><q id='tLarw'></q></dir></style></legend>