반응형

/etc/rc.local 에 mysql을 등록 했었는데, 


mysql이 실행되기도 전에 서버 서비스를 위한 java 데몬이 실행되면서 DB를 찾지 못하고 꺼져버리는 문제 발생.!!!


소스로 설치한 mysql은 따로 service에 등록해야 됩니다.


서비스가 먼저 실행되고 rc.local이 실행되며 정상적으로 게임 서비스가 되네요.


등록방법은 아래와 같습니다.


mysql 자동실행 설정

/usr/local/mysql/support-files/mysql.server 를  /etc/init.d 에 mysqld 로 복사. 

# chkconfig --add mysqld 
# chkconfig --level 2345 mysqld on 
# chmod 755 /etc/rc.d/init.d/mysqld
이제 ntsysv 에서 확인하시거나 top를 통해 확인해 보시면 mysqld 가 추가되어 있을겁니다.


^ㅡ^ 쉽죠?






반응형
반응형


mysql 5.5 은 yum 기본설치로는 설치할수 없습니다. 


구글링 하다가 mysql 5.5를 yum을 통해서 설치하는 법이 있어서 스크랩 차원에서 남겨둡니다.



Step 1: Installing Remi Repository

Firstly, we need to install the Remi repository on your selected Linux distributions.

For Fedora 18-12

## Install Remi Repository on Fedora 17, 16, 15
rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm 
rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

## Fedora 18 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-18.rpm

## Fedora 17 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-17.rpm

## Fedora 16 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-16.rpm

## Fedora 15 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-15.rpm

## Fedora 14 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-14.rpm

## Fedora 13 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-13.rpm

## Fedora 12 ##
rpm -Uvh http://rpms.famillecollet.com/remi-release-12.rpm

For RHEL/CentOS 6-5

## Install Remi Repository on RHEL/CentOS 6.7-6.0 ##
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm 

## Install Remi Repository on RHEL/CentOS 5.4-5.0 ##
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

Step 2. Checking MySQL 5.5.30 Availability

After, installing Remi repository on your system, then look for MySQL latest version using –enablerepo=remi switch option.

# yum --enablerepo=remi list mysql mysql-server

Sample Output:

Available Packages
mysql.i686		5.5.30-1.el6.remi	remi
mysql-server.i686	5.5.30-1.el6.remi       remi

Step 3: Updating or Installing MySQL 5.5.30

Once you see the latest MySQL version is available for installation, then follow below steps to update or install MySQL 5.5.30.

# yum --enablerepo=remi install mysql mysql-server

Step 4: Starting/Stopping MySQL Server

Follow the below command to start/stop of the MySQL service.

# /etc/init.d/mysqld start
# /etc/init.d/mysqld stop
# /etc/init.d/mysqld status

Step 5: Connecting to MySQL Server

Connecting to newly installed MySQL server by providing username and password. If you haven’t yet set any password for your MySQL installation the simply hit enter.

# mysql -u root -p

Sample Output:

[root@twiki ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 1052
Server version: 5.5.30 MySQL Community Server (GPL) by Remi

Copyright (c) 2000, 2011, 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>

That’s it, you’ve successfully installed MySQL 5.5.30 on your system. If you’re having any trouble installing feel free to use our comment section for solutions.

출처 : http://www.tecmint.com/install-mysql-on-rhel-centos-6-5-fedora-17-12/






반응형
반응형

* 컴파일 및 설치를 위한 기본 환경 만들기

기본 컴파일을 위해 cmake가 설치되어 있어야 하며, 방법은 제가 작성한 cmake 설치 포스팅을 참조하면 됨.

그리고 mysql을 컴파일 하기 위해 필요한 기본 라이브러리 들을 설치 한다.


§ Prepare ENV

[root]# yum -y install zlib curl openssl openssl-devel libtermcap-devel libc-client-devel bison ncurses-devel bzip2-devel

* 컴파일 및 설치

§ Download postgresql source

[root]# wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.10.tar.gz/from/http://cdn.mysql.com/

 

§ Compile & Install postgresql source

[root]# tar xfvz mysql-5.6.10.tar.gz

[root]# cd mysql-5.6.10

[root]# cmake \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_EXTRA_CHARSETS=all \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.socket \

-DMYSQL_TCP_PORT=3306

[root]# gmake

[root]# gmake install

* 실행 및 테스트

§ Prepare User & Group

[root]# groupadd dba

[root]# useradd -g dba mysql

 

§ Create default Database

[root]# cd /usr/local/mysql

[root]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

[root]# chown -R mysql:dba /usr/local/mysql/

 

§ Prepare ENV

[root]# cp support-files/mysql.server /etc/init.d/mysqld

[root]# chmod 755 /etc/init.d/mysqld
[root]# cp support-files/my-default.cnf /etc/my.cnf (만약 덮어 써야 하는지 물어 보면 : yes)

[root]# mkdir /var/lib/mysql

 

[root]# vi /etc/init.d/mysqld

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

[root]# su - mysql

 

[mysql]# vi .bash_profile (아래내용 제일 마지막 줄에 추가)

export MYSQL_HOME=/usr/local/mysql

export PATH=$PATH:$MYSQL_HOME/bin:.

[root]# source .bash_profile


§ Run the Server

[mysql]# service mysqld start <-- server 시작

[mysql]# ln -s /usr/local/mysql/mysql.socket /var/lib/mysql/mysql.sock <-- 처음에 한번 심볼릭 링크 만들어 줌.

[mysql]# mysql -u root

mysql> show databases;

mysql> exit

 

§ Stop the Server

[mysql]# service mysqld stop <-- server 종료 

* 설치 후 작업

※ 만약 mysql을 종료 하였다면, 다시 시작합니다.

[root]# su - mysql

[mysql]# service mysqld start


§ Set root password

[root]# mysqladmin -u root password 'password 설정'


§ Create a DB

[root]# mysql -u root -p
Enter password: <설정한 비밀번호 입력>

mysql> create database <생성하고 싶은 database 이름>;

§ Set a Connection policy

mysql> grant all privileges on <DB이름>.* to 'USERNAME'@'%' identified by 'PASSWORD';
mysql> flush privileges;

※ root 권한에 대해 외부에서 접속하게 하고자 할 때
mysql> grant all privileges on *.* to 'root'@'%' identified by 'root의 패스워드';

 


인터넷에 있는 방법들을 다 써보다가 멘붕오고 


이 내용이 저랑 맞는지 잘 설치되어서 두고 두고 사용하려고 스크랩 합니다.


출처 : http://blog.naver.com/PostView.nhn?blogId=albertx&logNo=100179681424


반응형
반응형


Mysql 5.5 RPM  설치시 아래와 같은 에러가 발생하면 libaio가 없다는 이야기 입니다. 


설치해 주시면 됩니다 ^^


[root@ittz]# rpm -ivh MySQL-server-5.6.17-1.el6.x86_64.rpm

error: Failed dependencies:

        libaio.so.1()(64bit) is needed by MySQL-server-5.6.17-1.el6.x86_64

        libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.6.17-1.el6.x86_64

        libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.6.17-1.el6.x86_64




libaio 설치 여부 확인


[root@ittz]# rpm -q --provides libaio

package libaio is not installed


역시나 없네요. 





yum install libaio 명령어로 설치하시고 다시 rpm 설치 진행하시면 ㄷ

반응형
반응형

Join 에는 여러 문법이 있지만. 



무조건 왼쪽 기준으로 정렬하게 되는 LEFT JOIN 을 가장 많이 쓰게 되는것 같습니다. 



ex) select * from tb_user a left join tb_id b on a.id=b.id ;

LEFT JOIN은 위와 같이 쓰는게 가장 보편적입니다. 


tb_user 테이블의 별칭 a, tb_id 테이블의 별칭 b


ON  절에서 a의 id와 b의 id를 붙여주면 

a 기준으로 b의 값들이 조인합니다. 



여기에 조건이 추가되죠 where a.id=10; 

a.id가 10인 애들만 선택됩니다. 

ex) select * from tb_user a left join tb_id b on a.id=b.id where a.id=10; 


근데 난감한게 b의 값 기준으로 선택하고 싶습니다. 

그때는 on절에 and를 이용하여 값을 추가하면 됩니다. 

ex) select * from tb_user a left join tb_id b on a.id=b.id and b.name='빵구똥꾸' where a.id=10; 


그러면 a.id가 10이면서 b.name가 빵꾸똥꾸인 애들만 조인됩니다. 








반응형

'MySql,MsSql' 카테고리의 다른 글

[SQL] Ranking을 SQL로 구현  (0) 2013.06.28
[sql] null 을 제외한 오름차순 정렬 쿼리  (0) 2013.01.26

+ Recent posts