错误1698(28000):在ubuntu上的新安装上执行mysql\u secure\u安装时,拒绝用户“root”@“localhost”的访问

xienkqul  于 2021-06-24  发布在  Mysql
关注(0)|答案(1)|浏览(326)

我刚刚使用以下命令在ubuntu系统上安装了mysql服务器

sudo apt-get update
sudo apt-get install mysql-server

我没有为root用户设置任何密码。
然后根据https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-16-04
我要跑了

mysql_secure_installation

以确保安装安全
但是运行上面的命令,会显示以下错误。

sugushiva@instance-1:~$ mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Enter current password for root (enter for none): 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
Enter current password for root (enter for none):

它说如果它是一个新的安装,我可以只按回车键,但如果我按回车键它抛出错误

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

在网上搜索发现
https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost#=
根据以上网址
我需要为根用户更改插件或创建一个新用户,建议创建一个新用户
我担心更改默认的根用户插件时可能会出现一些安全问题。
但是我的mysql\u secure\u安装需要root密码。
etra信息:

sugushiva@instance-1:~$ sudo mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.1.26-MariaDB-0+deb9u1 Debian 9.1
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
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
MariaDB [mysql]> select user, plugin from user
    -> ;
+------+-------------+
| user | plugin      |
+------+-------------+
| root | unix_socket |
+------+-------------+

它是google云计算引擎的虚拟机示例

yrwegjxp

yrwegjxp1#

方法:更改根验证方法

****strong text从终端打开mysql提示符:

1) sudo mysql
2) 从mysql.user中选择user,plugin,host,其中user='root';
3) 通过“在此处输入密码”更改用mysql_native_密码标识的用户“root”@“localhost”;
4) 刷新特权;
您现在应该可以使用根帐户登录到phpmyadmin。

相关问题