- 출력결과
[출처] http://blog.naver.com/yjhyjh5369/80188783143
[출처] [MySQL] MySQL 접속제한 해제|작성자 주한길
'MySQL' 카테고리의 다른 글
| [MySQL] MySQL 계정 생성 (0) | 2015.07.09 |
|---|---|
| [MySQL] MySQL 함수 정리 (숫자, 문자, 날짜) (0) | 2015.07.09 |
| [MySQL] MySql root 패스워드 설정 및 비번 변경과 root 비번 잃어버렸을 경우 (0) | 2015.07.09 |
| [MySQL] How can I reset my MySQL password? (영문) (0) | 2015.07.09 |
| [MySQL] Access denied for user 'root'@'localhost' (using password: YES) 오류해결 (0) | 2015.07.09 |
초기 mysql root 패스워드 설정 및 비번 변경과 root 비번 잃어버렸을 경우 변경 하는방법
1. 초기 mysql root 패스워드 설정하기
mysql 서버에 패스워드 없이 로그인 하게되면 서버에 만들어진 데이터베이스나 테이블
기타 이곳에 저장된 자료가 외부인에게 노출될 수 있다.
따라서 이러한 보안을 목적으로 root 패스워드를 지정하면 mysql 서버를 안전하게 보호할 수 있다.
mysql> use mysql;
mysql> update user set password=password('123456') where user='root';
Query OK, 2 rows affected (0.03 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> flush privileges; <--- 적용
flush privileges; 를 하지 않으면 mysql에서 빠져나와서 root 로그인이 안된다.
확인한다.
mysql> select host, user, password from user;
+----------------------------------------------------------------+
| Host user password |
+----------------------------------------------------------------+
| localhost root 2e01146f5c065853 |
| localhost.localdomain root 2e01146f5c065853 |
+----------------------------------------------------------------+
mysql> \q
Bye
------------------------------------------------------------------------------------
[주의]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
그대는 mysql 을 shutdown 하거나 reload 하면 된다.
# /usr/local/mysql/bin/mysqladmin -u root -p shutdown
하면 패스워드를 묻는데 이때 입력하면 설정한 mysql이 적용이된다.
# /usr/local/mysql/bin/mysqladmin -u root -p reload;
------------------------------------------------------------------------------------
# mysql -u root -p [Enter] // root 패스워드로 로그인
Enter password: ******
※ Mysql 서버에 root 패스워드가 설정되면 이제 부터는 mysql 서버에 접속하기 위해서는
위와 같이 -u 뒤에 root입력하고 -p 옵션을 사용하여 패스워드를 사용한다는 것을 명시해야 한다.
그리고 엔터를 치면 root 패스워드를 입력받기 위해 커서가 멈춘다.
(mysql 명령어만 입력하고 엔터를 치면 패스워드를 묻지 앟고 바로 mysql> 프롬프트가 나온 옛 시절을 생각해 보면 금방 차이를 느낄수 있음)
2. 루트 비번 변경
mysql> use mysql;
mysql> update user set password=password('123456') where user='root';
mysql> flush privileges;
3. root 패스워드를 분실한 경우(응급조치)
mysql을 오랫동안 사용하지 않았을 경우에 간혹 root패스워드가 기억나질않아서 당황할 때가 있습니다. 시스템관리자라면 시스템의 root나 MySQL의 root의 암호를 잊어 버렸을 때를 대비해서 패스워드를 새로 설정하는 방법을 반드시 숙지하고 있어야 할 것입니다.
① 실행중인 msyql 종료
# ps -ef | grep mysqld
root 9567 1 0 Mar16 ? 00:00:00 sh ./mysqld_safe
root 9576 9567 0 Mar16 ? 00:00:00 /usr/local/mysql/libexec/mysqld
root 9578 9576 0 Mar16 ? 00:00:00 /usr/local/mysql/libexec/mysqld
root 9579 9578 0 Mar16 ? 00:00:00 /usr/local/mysql/libexec/mysqld
# killall mysqld
② grant-table 미사용모드로 mysql시작(권한 테이블을 사용하지 않는 옵션으로 데몬 실행)
nt일 경우 :
c:\program files\mysql\mysql server 4.1\bin>mysqld-nt --standalone --skip-grant-tables
만약 Error 2003 Hy000 Can't connect to MySQL server on 'localhost' 와 같은 메세지가 나온다면
c:\program files\mysql\mysql server 4.1\bin>mysqld --defaults-file="c:\program files\mysql\mysql server 4.1\my.ini" --consol --skip-grant-tables
따로 프롬프트는 떨어지지 않으므로 새로 cmd창을 열어서 접속해 본다.
# ./safe_mysqld --skip-grant-tables &
[1] 12084
# Starting mysqld daemon with databases from /usr/local/mysql/data
#
# ./mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 3.22.24
Type 'help' for help.
mysql>
※ mysqld_safe 명령어는 mysql 데몬을 실행시킨다.
③ update문으로 root사용자 패스워드 갱신
mysql> update user set password=password('123') where user = 'root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> \q
Bye
④ 실행중인 mysql 다시 종료(권한 테이블을 사용하지 않는 데몬을 종료)
# ps -ef | grep mysqld
root 12084 11558 0 20:10 pts/2 00:00:00 sh ./mysqld_safe --skip-grant-ta
root 12090 12084 0 20:10 pts/2 00:00:00 /usr/local/mysql/libexec/mysqld
root 12092 12090 0 20:10 pts/2 00:00:00 /usr/local/mysql/libexec/mysqld
root 12093 12092 0 20:10 pts/2 00:00:00 /usr/local/mysql/libexec/mysqld
#
# killall mysqld
mysqld daemon ended
[1]+ Done ./mysqld_safe --skip-grant-tables
#
⑤ Mysql 데몬 재 실행 후 갱신된 패스워드로 로그인
# ./safe_mysqld &
[1] 12102
# Starting mysqld daemon with databases from /usr/local/mysql/data
#
# ps -ef | grep mysql
root 12102 11558 0 20:13 pts/2 00:00:00 sh ./mysqld_safe
root 12108 12102 0 20:13 pts/2 00:00:00 /usr/local/mysql/libexec/mysqld
root 12110 12108 0 20:13 pts/2 00:00:00 /usr/local/mysql/libexec/mysqld
root 12111 12110 0 20:13 pts/2 00:00:00 /usr/local/mysql/libexec/mysqld
# mysql -u root -p
Enter Password: ***************
'MySQL' 카테고리의 다른 글
| [MySQL] MySQL 함수 정리 (숫자, 문자, 날짜) (0) | 2015.07.09 |
|---|---|
| [MySQL] MySQL 접속제한 해제 (0) | 2015.07.09 |
| [MySQL] How can I reset my MySQL password? (영문) (0) | 2015.07.09 |
| [MySQL] Access denied for user 'root'@'localhost' (using password: YES) 오류해결 (0) | 2015.07.09 |
| [MySQL] MySQL JOIN 걸어서 업데이트(UPDATE) 하기 (0) | 2015.07.09 |
Following this procedure, you will disable access control on the MySQL server. All connexions will have a root access. It is a good thing to unplug your server from the network or at least disable remote access.
To reset your mysqld password just follow these instructions :
- Stop the mysql demon process using this command :
sudo /etc/init.d/mysql stop
- Start the mysqld demon process using the --skip-grant-tables option with this command
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
Because you are not checking user privs at this point, it's safest to disable networking. In Dapper, /usr/bin/mysqld... did not work. However, mysqld --skip-grant-tables did.
- start the mysql client process using this command
mysql -u root
- from the mysql prompt execute this command to be able to change any password
FLUSH PRIVILEGES;
- Then reset/update your password
SET PASSWORD FOR root@'localhost' = PASSWORD('password');
- If you have a mysql root account that can connect from everywhere, you should also do:
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
- Alternate Method:
USE mysql UPDATE user SET Password = PASSWORD('newpwd') WHERE Host = 'localhost' AND User = 'root';
- And if you have a root account that can access from everywhere:
USE mysql UPDATE user SET Password = PASSWORD('newpwd') WHERE Host = '%' AND User = 'root';
For either method, once have received a message indicating a successful query (one or more rows affected), flush privileges:
FLUSH PRIVILEGES;
Then stop the mysqld process and relaunch it with the classical way:
sudo /etc/init.d/mysql stop sudo /etc/init.d/mysql start
When you have completed all this steps ,you can easily access to your mysql server with the password you have set in the step before. An easy way to have a full control of your mysql server is phpmyadmin (www.phpmyadmin.net), software made in php that can give you a web interface that can be very usefull to people that havent got a lot of confidence with bash .To install phpmyadmin on you server you will need to have 4 things:
- web server apache
- php
- mysql server/mysql client installed
- php_mysql support for apache
All packages can be found browsing synaptic.
'MySQL' 카테고리의 다른 글
| [MySQL] MySQL 접속제한 해제 (0) | 2015.07.09 |
|---|---|
| [MySQL] MySql root 패스워드 설정 및 비번 변경과 root 비번 잃어버렸을 경우 (0) | 2015.07.09 |
| [MySQL] Access denied for user 'root'@'localhost' (using password: YES) 오류해결 (0) | 2015.07.09 |
| [MySQL] MySQL JOIN 걸어서 업데이트(UPDATE) 하기 (0) | 2015.07.09 |
| [MySQL] MySQL 데이터베이스 추가 및 사용자 추가 (0) | 2015.07.09 |
MySQL에서 Access denied for user 'root'@'localhost' (using password: YES) 오류해결
# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
이러한 오류의 경우에는 MySQL의 패스워드를 재설정해줘야 한다:
# service mysql stop
# mysqld --skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=password('password를 입력한다') where user='root';
mysql> flush privileges;
mysql>quit
# service mysql start
[출처] http://blog.naver.com/yoosy0302/130113061219
'MySQL' 카테고리의 다른 글
| [MySQL] MySql root 패스워드 설정 및 비번 변경과 root 비번 잃어버렸을 경우 (0) | 2015.07.09 |
|---|---|
| [MySQL] How can I reset my MySQL password? (영문) (0) | 2015.07.09 |
| [MySQL] MySQL JOIN 걸어서 업데이트(UPDATE) 하기 (0) | 2015.07.09 |
| [MySQL] MySQL 데이터베이스 추가 및 사용자 추가 (0) | 2015.07.09 |
| ★ MySQL DB SQL Statement (0) | 2015.04.23 |
DB작업을 하다보면 JOIN을 걸어서 UPDATE를 해야 할 경우가 간간히 생기는데요, MySQL에서는 서브쿼리 이딴거 필요 없습니다. 걍 우리가 아는 JOIN문 비스무레하게 아래 형식처럼 작성해 주시면 됩니다.
형식)
|
조건이 필요한 경우는 WHERE 절 이하를 작성해 주시면 되고 필요한 조건이 없다면 생략하시면 됩니다.
예1)은 회원테이블과 후원테이블을 아이디로 INNER 조인을 건다음 회원등급이 9이면서, 후원금이 10000 이상
인 사람의 회원등급을 7로 변경해주는 쿼리의 예입니다.
예1)
| UPDATE 후원테이블 A INNER JOIN 회원테이블 B ON A.회원아이디 = B.회원아이디 SET B.회원등급 = 7 WHERE B.회원등급 = 9 AND A.후원금 >= 10000 |
예2)는 실제 테이블 적용 예입니다.
예2)
| UPDATE support_table A INNER JOIN member_table B ON A.sp_uid=B.user_id SET B.level=7 WHERE B.level=9 AND A.support_money > 10000 |
From : 높이뜬새(www.webmadang.net)
[출처] http://www.webmadang.net/database/database.do?action=read&boardid=4003&page=1&seq=24
'MySQL' 카테고리의 다른 글
| [MySQL] How can I reset my MySQL password? (영문) (0) | 2015.07.09 |
|---|---|
| [MySQL] Access denied for user 'root'@'localhost' (using password: YES) 오류해결 (0) | 2015.07.09 |
| [MySQL] MySQL 데이터베이스 추가 및 사용자 추가 (0) | 2015.07.09 |
| ★ MySQL DB SQL Statement (0) | 2015.04.23 |
| PHP에서 지원하는 MySQL API함수 (0) | 2015.04.23 |



