mySQL: "Access denied for user ' root' @'localhost"安装软件后

标签 mysql linux

我刚刚在一台Linux机器上安装了mySQL 5.1.55,好像没问题

# /usr/local/mysql/bin/mysql_install_db
Installing MySQL system tables...
160606 21:46:25 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
Filling help tables...
160606 21:46:26 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/mysql-5.1.55/bin/mysqladmin -u root password 'new-password'

Alternatively you can run:
/usr/local/mysql-5.1.55/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr/local/mysql-5.1.55 ; /usr/local/mysql-5.1.55/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql-5.1.55/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/mysql-5.1.55/bin/mysqlbug script!

但是,如果我运行

# /usr/local/mysql-5.1.55/bin/mysqladmin -u root password foo

我收到此错误消息:

/usr/local/mysql-5.1.55/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

如果我运行:

# /usr/local/mysql-5.1.55/bin/mysql -u root -p

我不知道密码是:-S

欢迎任何帮助。非常感谢。

最佳答案

如果没有运行就安装了mysql

> mysql_secure_installation

脚本根本不应该有密码。只需输入

> mysql 

看看会发生什么。如果失败,您仍然可以在 mysql manual 之后设置一个新的 root 密码。

关于mySQL: "Access denied for user ' root' @'localhost"安装软件后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37665928/

相关文章:

linux - 两次调用waitpid时出现"no child process"错误

linux - 合并分割的 tar.gz 文件的某些部分 Linux 命令

SQL 查询的 PHP 输出

php - 如何在 JOIN 子句中使用 SELECT 语句?

java - 如何确定 SOLR 索引的字段类型?

linux - 使用 eclipse 在 linux 上进行 qt 开发?

用于 clojure 开发的 Linux 与 Windows

php - 如果为空变量

php - 挣扎于简单的 SQL 查询

linux - 如何在Linux中强制使具有 's'权限的命令崩溃?