我刚刚使用以下命令在ubuntu系统上安装了mysql-server
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):
它说如果是全新安装,我可以按Enter键,但是如果我按Enter键,则会引发错误
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
在线搜索并找到以下内容
https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost#=
根据上述网址
我需要为root用户更改插件或创建一个新用户,建议创建一个新用户
恐怕更改默认的root用户插件可能会遇到一些安全问题。
但是我的mysql_secure_installation需要root密码。
更多信息:
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云计算引擎的虚拟机实例
答案 0 :(得分:0)
方法:更改根身份验证方法
**** strong文本从终端打开MySQL提示:
1)sudo mysql
2)从mysql.user中选择用户,插件,主机,其中user ='root';
3)用mysql_native_password标识ALTER USER'root'@'localhost' 'enter_password_here';
4)冲洗特权;
您现在应该可以使用您的根帐户登录phpMyAdmin。