簡體   English   中英

無法使用Vagrant登錄到mysql服務器

[英]can't login to mysql server with Vagrant

我正在使用Vagrant並構建我的開發環境和bash腳本配置。 這是與MySQL有關的部分

echo "Preparing MySQL"
apt-get install debconf-utils -y > /dev/null
debconf-set-selections <<< "mysql-server mysql-server/root_password password"
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password"

echo "Installing MySQL"
apt-get install mysql-server -y > /dev/null

當我用vagrant ssh進入並運行mysql -u root -p提示我輸入密碼並將其放入,但是它總是說

ERROR 1045 (28000): Access denied for user 'vagrant'@'localhost' (using password: YES). 

我理解該錯誤,但我是Vagrant的新手,確實可以通過終端進行工作。 我該怎么做才能幫助發現和解決問題?

在我的Vagrantfile中,我聲明config.vm.network "private_network", ip: "172.22.22.22"如果有什么不同的話

嘗試更改服務器版本mysql-server-5.5而不是mysql-server

進行首次手動配置后,通常可以通過sudo debconf-get-selections找到所有手動提供的配置。

除此之外,您需要在命令行中設置密碼:

sudo debconf-set-selections <<< "mysql-server-5.5 mysql-server/root_password password mypass"
sudo debconf-set-selections <<< "mysql-server-5.5 mysql-server/root_password_again password mypass"
sudo apt-get install mysql-server -y

前三個命令可與Ubuntu 14.04一起使用,但mysql版本可能有所不同。 第一部分始終是程序包名稱。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM