I'm trying to set the password of the user root but I'm gettin the error below, any idea?
我试着设置用户根的密码但是我在下面出错了,有什么想法吗?
+----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost |
+----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*436576511F70A4E3B305E1AB8E209851945D8687' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> exit
Bye
root@tirengarfio:/var/www/rs2# mysqladmin -u root password foo,
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
8 个解决方案
#1
38
$ mysqladmin -u root -p password
Enter password:
New password:
Confirm new password:
password
is to be typed literally. It's a command. You don't have to substitute password
with your actual password.
密码是按字面意思输入的。这是一个命令。您不必用您的实际密码替换密码。
#2
36
# /etc/init.d/mysqld stop
Stopping MySQL: [ OK ]
# mysqld_safe --skip-grant-tables &
[1] 13694
# Starting mysqld daemon with databases from /var/lib/mysql
# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
#3
5
Set/Change password:
设置/修改密码:
mysqladmin -u root -p password
Login to MySQL console:
登录到MySQL控制台:
mysql -u root -p
To exit the console:
退出控制台:
.\q
#4
1
when trying to run this command i got the same error
当试图运行这个命令时,我得到了相同的错误。
sudo mysqladmin create asteriskcdrdba
i simply add a few lines to the code
我只是在代码中添加了几行代码。
-u root -p
and pressed the enter key. i then typed my password and hit enter. Linux liked my command as nothing more was displayed
然后按下回车键。然后输入密码并按回车键。Linux喜欢我的命令,因为没有更多的显示。
so maybe try
所以试着
sudo <your command here> -u <username> -p
after that hit enter and enter your password
然后点击进入并输入您的密码。
#5
1
This is basically a more detailed version of a previous answer.
这基本上是之前答案的一个更详细的版本。
In your Terminal, go to the location of your utility program, mysqladmin
在你的终端,到你的实用程序的位置,mysqladmin。
For example, if you were doing local development and using an application like M/W/XAMP, you might go to the directory:
例如,如果您正在进行本地开发,并使用像M/W/XAMP这样的应用程序,您可能会访问该目录:
/Applications/MAMP/Library/bin
/应用程序/ MAMP /图书馆/ bin
This is where mysqladmin resides.
这就是mysqladmin所在的地方。
If you're not using an application like MAMP, you may also be able to find your local installation of mysql at: /usr/local/mysql
如果您没有使用像MAMP这样的应用程序,您也可以在:/usr/local/mysql中找到您的本地安装。
And then if you go to: /usr/local/mysql/bin/
然后如果你去:/usr/local/mysql/bin/。
You are in the directory where mysqladmin resides.
您在mysqladmin所在的目录中。
Then, to change the password, you will do the following:
然后,要更改密码,您将执行以下操作:
-
At your Terminal prompt enter the exact command below (aka copy and paste) and press enter. The word "password" is part of the command, so don't be confused and come to the conclusion that you need to replace this word with some password you created previously or want to use in the future. You will have a chance to enter a new password soon enough, but it's not in this first command that you will do that:
在您的终端提示输入下面的精确命令(即复制和粘贴)并按回车。“password”一词是该命令的一部分,所以不要混淆,并得出结论,你需要用你以前创建的密码来替换这个单词,或者在将来使用它。你很快就会有机会输入一个新的密码,但这不是第一个命令,你会这样做:
./mysqladmin -u root -p password
./mysqladmin -u root -p密码。
-
The Terminal will ask you to enter your original or initial password, not a new one yet. From the above image you provided, it looks like you have one already created, so enter it here:
终端会要求你输入你的初始密码或初始密码,而不是新的密码。从上面你提供的图片,看起来你已经创建了一个,所以在这里输入:
Enter password:
oldpassword
输入密码:oldpassword
- The Terminal will ask you to enter a new password. Type it here and press enter:
- 终端会要求你输入一个新的密码。在这里输入并按回车键:
New password:
newpassword
新密码:newpassword
- Then the Terminal will ask you to confirm the new password. Type it here and press enter:
- 然后终端会要求你确认新的密码。在这里输入并按回车键:
Confirm new password:
newpassword
确认新密码:newpassword
Reset or restart your Terminal.
重置或重启你的终端。
In some cases, as with M/W/XAMP, you will have to update this new password in various files in order to get your application running properly again.
在某些情况下,如使用M/W/XAMP,您将不得不在各种文件中更新这个新密码,以使您的应用程序再次正常运行。
#6
1
Those are all good answers, but don't quite touch the deep cause of the problem one most likely has if faced with the OP question. That is, not knowing the ORIGINAL "starting" password created during the installation time.
这些都是很好的答案,但却不能触及问题的深层原因。也就是说,不知道在安装期间创建的原始“启动”密码。
And all these command lines with "-u root ..." etc. imply knowing and using THAT password.
所有这些带有“-u root…”的命令行意味着知道并使用该密码。
Now this part from the original installation message may help anyone facing the problem above:
现在,来自原始安装消息的这一部分可以帮助任何面对上述问题的人:
Initial password for first time use of MySQL is saved in $HOME/.mysql_secret
ie. when you want to use "mysql -u root -p" first you should see password
in /root/.mysql_secret
首次使用MySQL的初始密码保存在$HOME/中。mysql_secret ie。当您想要使用“mysql -u root -p”时,首先应该在/root/.mysql_secret中看到密码。
#7
-1
Firstly, go to the folder support-files on terminal, and start the server by mysql.server start, Secondly, go to the folder bin on terminal or type /usr/local/mysql/bin/mysqladmin -u root -p password
首先,到终端上的文件夹支持文件,然后用mysql启动服务器。服务器启动,其次,到终端或类型/usr/local/mysql/bin/mysqladmin -u root -p密码的文件夹bin。
It would ask you for the old temporary password which was given to you while installing Mysql, type that and type in your new password and it would work.
它会询问你在安装Mysql时给你的旧的临时密码,在你的新密码中输入和输入你的新密码。
#8
-3
- open
my.cnf
using following path - 使用以下路径打开my.cnf。
C:\xampp\mysql\bin
C:\ xampp \ mysql \ bin
-
under #
The following options will be passed to all MySQL clients#password
remove#
comment sign if it is therepassword = "newpassword"
下面的选项将会传递给所有MySQL客户端#密码删除#注释,如果它有密码= "newpassword"
-
save file
保存文件
-
close file
关闭文件
-
re-start mysql
重启mysql
#1
38
$ mysqladmin -u root -p password
Enter password:
New password:
Confirm new password:
password
is to be typed literally. It's a command. You don't have to substitute password
with your actual password.
密码是按字面意思输入的。这是一个命令。您不必用您的实际密码替换密码。
#2
36
# /etc/init.d/mysqld stop
Stopping MySQL: [ OK ]
# mysqld_safe --skip-grant-tables &
[1] 13694
# Starting mysqld daemon with databases from /var/lib/mysql
# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
#3
5
Set/Change password:
设置/修改密码:
mysqladmin -u root -p password
Login to MySQL console:
登录到MySQL控制台:
mysql -u root -p
To exit the console:
退出控制台:
.\q
#4
1
when trying to run this command i got the same error
当试图运行这个命令时,我得到了相同的错误。
sudo mysqladmin create asteriskcdrdba
i simply add a few lines to the code
我只是在代码中添加了几行代码。
-u root -p
and pressed the enter key. i then typed my password and hit enter. Linux liked my command as nothing more was displayed
然后按下回车键。然后输入密码并按回车键。Linux喜欢我的命令,因为没有更多的显示。
so maybe try
所以试着
sudo <your command here> -u <username> -p
after that hit enter and enter your password
然后点击进入并输入您的密码。
#5
1
This is basically a more detailed version of a previous answer.
这基本上是之前答案的一个更详细的版本。
In your Terminal, go to the location of your utility program, mysqladmin
在你的终端,到你的实用程序的位置,mysqladmin。
For example, if you were doing local development and using an application like M/W/XAMP, you might go to the directory:
例如,如果您正在进行本地开发,并使用像M/W/XAMP这样的应用程序,您可能会访问该目录:
/Applications/MAMP/Library/bin
/应用程序/ MAMP /图书馆/ bin
This is where mysqladmin resides.
这就是mysqladmin所在的地方。
If you're not using an application like MAMP, you may also be able to find your local installation of mysql at: /usr/local/mysql
如果您没有使用像MAMP这样的应用程序,您也可以在:/usr/local/mysql中找到您的本地安装。
And then if you go to: /usr/local/mysql/bin/
然后如果你去:/usr/local/mysql/bin/。
You are in the directory where mysqladmin resides.
您在mysqladmin所在的目录中。
Then, to change the password, you will do the following:
然后,要更改密码,您将执行以下操作:
-
At your Terminal prompt enter the exact command below (aka copy and paste) and press enter. The word "password" is part of the command, so don't be confused and come to the conclusion that you need to replace this word with some password you created previously or want to use in the future. You will have a chance to enter a new password soon enough, but it's not in this first command that you will do that:
在您的终端提示输入下面的精确命令(即复制和粘贴)并按回车。“password”一词是该命令的一部分,所以不要混淆,并得出结论,你需要用你以前创建的密码来替换这个单词,或者在将来使用它。你很快就会有机会输入一个新的密码,但这不是第一个命令,你会这样做:
./mysqladmin -u root -p password
./mysqladmin -u root -p密码。
-
The Terminal will ask you to enter your original or initial password, not a new one yet. From the above image you provided, it looks like you have one already created, so enter it here:
终端会要求你输入你的初始密码或初始密码,而不是新的密码。从上面你提供的图片,看起来你已经创建了一个,所以在这里输入:
Enter password:
oldpassword
输入密码:oldpassword
- The Terminal will ask you to enter a new password. Type it here and press enter:
- 终端会要求你输入一个新的密码。在这里输入并按回车键:
New password:
newpassword
新密码:newpassword
- Then the Terminal will ask you to confirm the new password. Type it here and press enter:
- 然后终端会要求你确认新的密码。在这里输入并按回车键:
Confirm new password:
newpassword
确认新密码:newpassword
Reset or restart your Terminal.
重置或重启你的终端。
In some cases, as with M/W/XAMP, you will have to update this new password in various files in order to get your application running properly again.
在某些情况下,如使用M/W/XAMP,您将不得不在各种文件中更新这个新密码,以使您的应用程序再次正常运行。
#6
1
Those are all good answers, but don't quite touch the deep cause of the problem one most likely has if faced with the OP question. That is, not knowing the ORIGINAL "starting" password created during the installation time.
这些都是很好的答案,但却不能触及问题的深层原因。也就是说,不知道在安装期间创建的原始“启动”密码。
And all these command lines with "-u root ..." etc. imply knowing and using THAT password.
所有这些带有“-u root…”的命令行意味着知道并使用该密码。
Now this part from the original installation message may help anyone facing the problem above:
现在,来自原始安装消息的这一部分可以帮助任何面对上述问题的人:
Initial password for first time use of MySQL is saved in $HOME/.mysql_secret
ie. when you want to use "mysql -u root -p" first you should see password
in /root/.mysql_secret
首次使用MySQL的初始密码保存在$HOME/中。mysql_secret ie。当您想要使用“mysql -u root -p”时,首先应该在/root/.mysql_secret中看到密码。
#7
-1
Firstly, go to the folder support-files on terminal, and start the server by mysql.server start, Secondly, go to the folder bin on terminal or type /usr/local/mysql/bin/mysqladmin -u root -p password
首先,到终端上的文件夹支持文件,然后用mysql启动服务器。服务器启动,其次,到终端或类型/usr/local/mysql/bin/mysqladmin -u root -p密码的文件夹bin。
It would ask you for the old temporary password which was given to you while installing Mysql, type that and type in your new password and it would work.
它会询问你在安装Mysql时给你的旧的临时密码,在你的新密码中输入和输入你的新密码。
#8
-3
- open
my.cnf
using following path - 使用以下路径打开my.cnf。
C:\xampp\mysql\bin
C:\ xampp \ mysql \ bin
-
under #
The following options will be passed to all MySQL clients#password
remove#
comment sign if it is therepassword = "newpassword"
下面的选项将会传递给所有MySQL客户端#密码删除#注释,如果它有密码= "newpassword"
-
save file
保存文件
-
close file
关闭文件
-
re-start mysql
重启mysql