MySQL 패스워드 초기설정 실패

1 문제상황[ | ]

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

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

2 원인[ | ]

  • 안전모드로 들어가 보니 계정 등을 관리하는 mysql DB가 아예 없다...
Console
Copy
[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 ~]#
Console
Copy
[root@zetawiki ~]# /usr/bin/mysql -u root mysql
ERROR 1049 (42000): Unknown database 'mysql'
Console
Copy
[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
Console
Copy
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)
mysql> quit
[root@zetawiki ~]#

3 해결방법[ | ]

mysql_install_db 을 실행해주자.

Console
Copy
[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!
Console
Copy
[root@zetawiki ~]# /usr/bin/mysql -uroot -e "show databases"
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+

4 후속 작업[ | ]

5 같이 보기[ | ]

  • CentOS MySQL 설치
    RHEL5.x 버전에서 MySQL-5.5.45 버전 설치시, /usr/bin/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data 와 같이 설정해 주지 않으면 정상 동작하지 않는 경우가 있었습니다. 확인 바랍니다.
  • MySQL BigDump
    'MySQL server has gone away'는 백업본 전체의 크기가 크다기 보다는, 특정 쿼리문 1개의 크기가 너무 커서 처리를 못하는 거라서, 이런 도구로 해결하기는 어려울 것 같습니다.J Jmnote
  • MySQL STRICT TRANS TABLES
    @Jmnote 감사합니다.~ John Jeong
  • MySQL 외래키 옵션 변경
    진짜 필요한 거였는데 이런걸 이제야 알다니 정말 감사합니다. 문태부
  • MySQL 컬럼명으로 테이블 찾기
    회사 가서 쓰기 좋은 코드 1추 Stly3466