해결책


GRANT ALL PRIVILEGES ON *.* TO <username>@'%' IDENTIFIED BY <password>;


신고

import java.sql.DriverManager;

import java.sql.Connection;

import java.sql.SQLException;


public class JDBCExample {


  public static void main(String[] argv) {


        System.out.println("-------- MySQL JDBC Connection Testing ------------");


        try {

                Class.forName("com.mysql.jdbc.Driver");

        } catch (ClassNotFoundException e) {

                System.out.println("Where is your MySQL JDBC Driver?");

                e.printStackTrace();

                return;

        }


        System.out.println("MySQL JDBC Driver Registered!");

        Connection connection = null;


        try {

                connection = DriverManager

                .getConnection("jdbc:mysql://localhost:3306/testDB","root", "password");


        } catch (SQLException e) {

                System.out.println("Connection Failed! Check output console");

                e.printStackTrace();

                return;

        }


        if (connection != null) {

                System.out.println("You made it, take control your database now!");

        } else {

                System.out.println("Failed to make connection!");

        }

  }

}

신고

sudo systemctl stop mysqld


mysqld_safe --skip-grant-tables &


mysql

mysql> use mysql

mysql> update user set password=PASSWORD('passwd') where User='root';

mysql> flush privileges;

신고

SHOW FULL COLUMNS FROM table_name;

신고

Reserved Words in MySQL 5.5.27

ACCESSIBLE ADD ALL
ALTER ANALYZE AND
AS ASC ASENSITIVE
BEFORE BETWEEN BIGINT
BINARY BLOB BOTH
BY CALL CASCADE
CASE CHANGE CHAR
CHARACTER CHECK COLLATE
COLUMN CONDITION CONSTRAINT
CONTITUTE CONVERT CREATE
CROSS CURRENT_DATE CURRENT_TIME
CURRENT_TIMESTAMP CURRENT_USER CURSOR
DATABASE DATABASES DAY_HOUR
DAY_MICROSECOND DAY_MINUTE DAY_SECOND
DEC DECIMAL DECLARE
DISTINCT DISTINCROW DIV
DOUBLE DROP DUAL
EACH ELSE ELSEIF
ENCLOSED ESCAPED EXISTS
EXIT EXPLAIN FALSE
FETCH FLOAT FLOAT4
FLOAT8 FOR FORCE
FOREIGN FROM FULLTEXT
GRANT GROUP HAVING
HIGH_PRIORITY HOUR_MICROSECOND HOUR_MINUTE
HOUR_SECOND IF IGNORE
IN INDEX INFILE
INNER INOUT INSENTIVE
INSERT INT INT1
INT2 INT3 INT4
INT8 INTERGER INTERVAL
INTO IS ITERATE
JOIN KEY KEYS
KILL LEADING LEAVE
LEFT LIKE LIMIT
LINEAR LINES LOAD
LOCALTIME LOCALTIMESTAMP LOCK
LONG LONGBLOB LONGTEXT
LOOP LOW_PRIORITY MASTER_SSL_VARIFY_SERVER_CERT
MATCH MAXVALUE MEDIUMBLOB
MEDIUMINT MEDIUMTEXT MIDDLEINT
MINUTE_MISROSECOND MINUTE_SECOND MOD
MIDIFIES NATUAL NOT
NO_WRI?tE_TO_BINLOG NULL NUMERIC
ON OPTIMIZE OPTION
OPTIONALLY OR ORDER
OUT OUTER OUTFILE
PRECISION PRIMARY PROCEDURE
PURGE RANGE READ
READS READ_WRITE REAL
REDERENCES REGEXP RELEASE
RENAME REFEAT REPLACE
REQUIRE RESIGNAL RESTRICT
RETURN REVOKE RIGHT
RLIKE SCHEMA SCHEMAS
SECIND_MISROSECOND SELECT SENSITIVE
SEPARATIR SET SHOW
SIGNAL SMALLINT SPATIAL
SPECIFIC SQL SQLEXCEPTION
SQLSTATE SQLWARNING SQL_BIG_RESULT
SQL_CALC_FOUND_ROWS SQL_SMALL_RESULT SSL
STARTING STRAIGHT_JOIN TABLE
TERMINATED THEN TINYBLOB
TINYINT TINYTEXT TO
TRAILING TRIGGER TRUE
UNDO UNION UNIQUE
UNLOCK UNSIGNED UPDATE
USAGE USE USING
UTC_DATE UTC_TIME UTC_TIMESTAMP
VALUES VARBINARY VARCHAR
VARCHARACTER VARYING WHEN
WHERE WHILE WITH
WRITE XOR YEAR_MONTH
ZEROFILL

New Reserved Words in MySQL 5.5

GENERAL IGNORE_SERVER_IDS MASTER_HEARTBEAT_PERIOD
MAXVALUE RESIGNAL SIGNAL
SLOW

 

신고

캐릭터 셋 utf-8 에서 euckr 로 바꾸는 예제

1) 확인
mysql> show variables like 'c%';

+--------------------------+----------------------------------------+
| Variable_name            | Value                                  |
+--------------------------+----------------------------------------+
| character_set_client     | utf8                                   |  <- 변경
| character_set_connection | utf8                                   |  <- 변경
| character_set_database   | utf8                                   |  <- 변경
| character_set_filesystem | binary                                 |
| character_set_results    | utf8                                   |  <- 변경
| character_set_server     | utf8                                   |  <- 변경
| character_set_system     | utf8                                   |
| character_sets_dir       | /usr/local/mysql/share/mysql/charsets/ |
| collation_connection     | utf8_general_ci                        |  <- 변경
| collation_database       | utf8_general_ci                        |  <- 변경
| collation_server         | utf8_general_ci                        |  <- 변경
| completion_type          | 0                                      |
| concurrent_insert        | 1                                      |
| connect_timeout          | 5                                      |
+--------------------------+----------------------------------------+


2) 변경 (일시적인 방법. MySQL을 재시작 하면 원래 값으로 돌아간다.)
msyql> set character_set_client = euckr;
msyql> set character_set_connection = euckr;
msyql> set character_set_database = euckr;
msyql> set character_set_results = euckr;
msyql> set character_set_server = euckr;
mysql> set collation_connection = euckr_korean_ci;
mysql> set collation_database = euckr_korean_ci;
mysql> set collation_server = euckr_korean_ci;

3) 확인
mysql> show variables like 'c%';
+--------------------------+----------------------------------------+
| Variable_name            | Value                                  |
+--------------------------+----------------------------------------+
| character_set_client     | euckr                                  |
| character_set_connection | euckr                                  |
| character_set_database   | euckr                                  |
| character_set_filesystem | binary                                 |
| character_set_results    | euckr                                  |
| character_set_server     | euckr                                  |
| character_set_system     | utf8                                   |
| character_sets_dir       | /usr/local/mysql/share/mysql/charsets/ |
| collation_connection     | euckr_korean_ci                        |
| collation_database       | euckr_korean_ci                        |
| collation_server         | euckr_korean_ci                        |
| completion_type          | 0                                      |
| concurrent_insert        | 1                                      |
| connect_timeout          | 5                                      |
+--------------------------+----------------------------------------+


4) 변경2 (온전한 변경 방법)

/etc/my.cnf 파일을 변경 해줍니다.

[client]
default-character-set=euckr

[mysqld]
default-character-set=euckr
init_connect=SET collation_connection=euckr_korean_ci
init_connect=SET NAMES euckr
character-set-server=euckr
collation-server=euckr_korean_ci

[mysqldump]
default-character-set=euckr

[mysql]
default-character-set=euckr

추가 및 변경 후, MySQL 을 재시작 해주어야 적용된다.


5) 아파치 캐릭터셋 확인

/usr/local/apache/conf/httpd.conf 파일을 변경(내용 추가)해줍니다.

AddCharset EUC-KR       .euc-kr

※ 참고1 : UTF-8사용 : AddCharset UTF-8        .utf8
    참고2 : Apache 버젼 2.2.6 이상의 경우, /usr/local/apache/conf/extra/httpd-languages.conf 를 수정.


신고

+ Recent posts