Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我无法连接到我刚刚安装的MySQL服务器_Mysql_Ubuntu - Fatal编程技术网

我无法连接到我刚刚安装的MySQL服务器

我无法连接到我刚刚安装的MySQL服务器,mysql,ubuntu,Mysql,Ubuntu,我已经在Ubuntu 16.04上安装了MySQL: sudo apt-get install mysql-client-5.7 mysql-server-5.7 要检查安装,请运行以下命令: mysql --version mysql Ver 14.14 Distrib 5.7.19, for Linux (x86_64) using EditLine wrapper 以及: systemctl status mysql.service ● mysql.service - MyS

我已经在Ubuntu 16.04上安装了MySQL:

sudo apt-get install mysql-client-5.7 mysql-server-5.7
要检查安装,请运行以下命令:

mysql --version

mysql  Ver 14.14 Distrib 5.7.19, for Linux (x86_64) using  EditLine wrapper
以及:

 systemctl status mysql.service

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2017-10-06 16:34:36 CEST; 28min ago
  Process: 3521 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 3511 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 3520 (mysqld)
   CGroup: /system.slice/mysql.service
           └─3520 /usr/sbin/mysqld

Oct 06 16:34:35 SV1080AP1105 systemd[1]: Starting MySQL Community Server...
Oct 06 16:34:36 SV1080AP1105 systemd[1]: Started MySQL Community Server.
但是当我尝试连接时,它不起作用

sudo mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

为什么要安装客户端软件包


请参阅:

较新版本的MySQL 5.7>和至少10.something>将root用户身份验证设置为auth_socket

这意味着root登录只能与root用户一起使用

尝试:

这是可以改变的,而且经常会改变,因为它阻碍了很多开发环境的工作,所以如果需要,有很多关于如何做到这一点的主题。

尝试以下方法:

    sudo grep 'temporary password' /var/log/mysqld.log
对于新安装,MySQL 5.7及更高版本会在日志中保存临时密码。这可能会有帮助

然后使用密码执行以下操作:

    sudo mysql -u root -p RETRIEVED_PASSWORD

你可以试试这个……我希望它能很好地工作

你必须使用密码,我想这真的取决于你在ubuntu上的用户帐户是如何设置的。我希望如果sudomysql不起作用,那么如果您的帐户已经是root/super用户,那么只需要mysql本身。如果仍然失败,您可能必须重置mysql的根密码。
    sudo mysql -u root -p RETRIEVED_PASSWORD
https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-16-04

https://help.ubuntu.com/lts/serverguide/mysql.html