ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [설치 & 셋팅 & 테스트]Mariadb 5.5
    카테고리 없음 2014. 3. 3. 13:03
    728x90

    1. 설치 방법


    https://downloads.mariadb.org/ 에서 자신의 환경에 맞는 stable(안정화?) 된 version을 Download 받는다.

    (이 글을 쓰는 시점에서는 5.5 였다.)

    Windows 에는 zip 형식과 mis 형식이 있는데, mis는 설치형 zip는 압축을 풀고 설정이 필요 하다.



    우선 나는 zip 형식으로 진행 한다. 압축파일을 원하는 위치에 풀어 놓으면 설치는 종료 이다.



    주요 설정

    설치된 디렉토리에서 

    my-huge.ini

    my-innodb-heavy-4G.ini

    my-large.ini

    my-medium.ini

    my-small.ini

    중 원하는 환경 기준으로 my-cnf.ini 로 명칭을 변경한다.





    mysqld 를 실행하면 mariadb 가 실행된다.

    mysqld

    또는

    mysqld --console


    root 패스워드 설정

    mysqladmin -u root password "new-password"

    * 패스 워드 설정 이후에는 root로만 접근 가능하다.




    이제 cmd 창에서 설치된 폴더로 이동하여, mysql 을 입력한다.

    mysql -u root -p


    2. character set 변경


    my-cnf.ini 파일에서 다음과 같이 추가 한다.

    [client]

    default-character-set=utf8


    [mysql]

    default-character-set=utf8



    [mysqld]

    collation-server = utf8_unicode_ci

    init-connect='SET NAMES utf8'

    character-set-server = utf8


    3. 권한 관리


    사용자 권한 관리는 각 table에서 insert 해주는 방법과 간한하게 grant를 이용한 방법이 있다.


    권한 추가

    grant all privileges on *.* to  USERNAME@'%' identified by 'PASSWORD' with grant option;

    flush privileges;


    권한 제거

    revoke all on `DB명`.* from USERNAME;

    revoke usage on `DB명`.* from USERNAME;

    flush privileges;



    4. java client 테스트


    먼저 mariadb-java-client-1.1.6.jar 파일을 다운받는다.


    그후 아래 코드와 같이 입력후 실행을 하여 콘솔 창에 OK!!가 보이면 성공이다.


    public class MariadbTest {
    
    	public static void main(String[] args) {
    		String driverName = "org.mariadb.jdbc.Driver";
    		String jdbcUrl = "jdbc:mariadb://172.20.204.147:3306/test";
    		String id = "lahuman";
    		String pw = "lahuman";
    		
    		Connection con = null;
    		try{
    			Class.forName(driverName);
    			con = DriverManager.getConnection(jdbcUrl, id, pw);
    			System.out.println("OK!!");
    		}catch(Exception e){
    			e.printStackTrace();
    		}finally{
    			if(con != null)
    				try {
    					con.close();
    				} catch (SQLException e) {
    					e.printStackTrace();
    				}
    		}
    		
    	}
    
    }
    



    참고 :

    https://mariadb.com/kb/en/iniciando-e-parando-mariadb-automaticamente/

    https://mariadb.com/kb/en/grant/

    https://mariadb.com/kb/en/configuring-mariadb-for-remote-client-access/

    http://stackoverflow.com/questions/3513773/change-mysql-default-character-set-to-utf8-in-my-cnf


    728x90
Designed by Tistory.