mySQL:“安装软件后,用户'root'@'localhost”拒绝访问

时间:2016-06-06 20:03:01

标签: 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

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

1 个答案:

答案 0 :(得分:0)

如果您已安装mysql而未运行

> mysql_secure_installation

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

即可
> mysql 

看看会发生什么。如果失败,您仍然可以在mysql manual

之后设置新的root密码