MySQL 패스워드 초기설정 실패

1 문제상황[ | ]

MySQL 최초 설치한 직후에 패스워드를 지정하려고 하는데 안된다...

[root@zetawiki ~]# /usr/bin/mysqladmin -u root password 'P@ssw0rd'
/usr/bin/mysqladmin: connect to server at 'localhost' failed

2 원인[ | ]

  • 안전모드로 들어가 보니 계정 등을 관리하는 mysql DB가 아예 없다...
[root@zetawiki ~]# /usr/bin/mysqld_safe --skip-grant &
[1] 20704
[root@zetawiki ~]# 131127 01:35:34 mysqld_safe Logging to '/var/log/mysqld.log'.
131127 01:35:34 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

[root@zetawiki ~]#
[root@zetawiki ~]# /usr/bin/mysql -u root mysql
ERROR 1049 (42000): Unknown database 'mysql'
[root@zetawiki ~]# /usr/bin/mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.34 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> update mysql.user set password=password('P@ssw0rd') where user='root';
ERROR 1146 (42S02): Table 'mysql.user' doesn't exist
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)
mysql> quit
[root@zetawiki ~]#

3 해결방법[ | ]

mysql_install_db 을 실행해주자.

[root@zetawiki ~]# mysql_install_db
Installing MySQL system tables...
OK
Filling help tables...
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/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h jmnote password 'new-password'

Alternatively you can run:
/usr/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 ; /usr/bin/mysqld_safe &

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

Please report any problems with the /usr/bin/mysqlbug script!
[root@zetawiki ~]# /usr/bin/mysql -uroot -e "show databases"
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+

4 후속 작업[ | ]

5 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}