Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Tuesday, October 8, 2019

MariaDB /usr/local/etc/my.cnf.d No such file or directory


$ mysql.server start
/usr/local/Cellar/mariadb/10.3.10/bin/my_print_defaults: Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2 "No such file or directory")
Fatal error in defaults handling. Program aborted
Starting MariaDB
./usr/local/Cellar/mariadb/10.3.10/bin/my_print_defaults: Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2 "No such file or directory")
Fatal error in defaults handling. Program aborted
/usr/local/Cellar/mariadb/10.3.10/bin/my_print_defaults: Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2 "No such file or directory")
Fatal error in defaults handling. Program aborted
191008 10:52:51 mysqld_safe Logging to '/usr/local/var/mysql/namjungsoo-MacBook-Pro.local.err'.
191008 10:52:51 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
ERROR!
해결 방법: 아래의 명령을 통해서 폴더를 만들어준다.
mkdir /usr/local/etc/my.cnf.d

Monday, September 16, 2019

MySQL timezone setting in Node.js sequelize

Wednesday, September 4, 2019

MariaDB Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

mysql.server start
Starting MariaDB
.190904 09:57:41 mysqld_safe Logging to '/usr/local/var/mysql/duongame-MacBook-Pro.local.err'.
190904 09:57:42 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
 SUCCESS!

Tuesday, December 22, 2015

MySQL C API에서 /var/lib/mysql/mysql.sock으로 접속이 안될때

MySQL Server를 설치한다.
yum -y install mysql mysql-server (or apt-get install mysql mysql-server)

Enable the MySQL service:
/sbin/chkconfig mysqld on

Start the MySQL server:
/sbin/service mysqld start

vi /etc/my.cnf
아래와 같이 클라이언트를 추가한다.
이미 있다면 수정하여 준다.

 [client]
 #password       = your_password
 host            = 127.0.0.1
 port            = 3306
 socket          = /var/run/mysql/mysql.sock

socket을 /var/lib/mysql/mysql.sock로 수정해주고
host를 127.0.0.1 또는 localhost로 수정해준다.
host는 여기에 입력한 대로 mysql_connect에서 호출해야 한다.(localhost로 입력했으면 127.0.0.1로는 접속안됨)

Tuesday, September 22, 2015

MySQL 초기 root 패스워드 설정하기

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password=password('password') where user='root';
Query OK, 4 rows affected (0.07 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.21 sec)

mysql> select host, user, password from user;
+----------------------+------------------+-------------------------------------------+
| host                 | user             | password                                  |
+----------------------+------------------+-------------------------------------------+
| localhost            | root             | *78D22DFB85972182BE20A883D8B5021FD8B5FCCA |
| yegam400.vps.phps.kr | root             | *78D22DFB85972182BE20A883D8B5021FD8B5FCCA |
| 127.0.0.1            | root             | *78D22DFB85972182BE20A883D8B5021FD8B5FCCA |
| ::1                  | root             | *78D22DFB85972182BE20A883D8B5021FD8B5FCCA |
| localhost            | debian-sys-maint | *E54187CB3AF30C421C5063781FEE02F787E6842F |
+----------------------+------------------+-------------------------------------------+

Monday, January 5, 2015

MySQL Error> 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)

MYSQL C API 사용시 아래와 같은 에러가 발생하는 경우가 있다.

MySQL Error> 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)

이 에러는  mysql_real_connect()에 host로 "localhost"를 넣는 경우 발생한다.
이럴 때는 host에 "localhost"대신에 "127.0.0.1"을 넣으면 문제가 해결된다.

MySQL libmysqlclient.so.18: cannot open shared object file: No such file or directory

CentOS에서 MySQL C API를 사용하는 프로그램을 실행 도중 위와 같은 에러가 발생했다.
find로 찾은 결과 다음과 같은 위치에 있었다.

[root@SE3576 src2]# find / -name  libmysqlclient.so.18
/usr/local/src/mysql-5.6.21/libmysql/libmysqlclient.so.18
/usr/local/mysql/lib/libmysqlclient.so.18

그래서 다음과 같이 LD_LIBRARY_PATH를 정해주어야 한다.
내가 작업하는 CentOS 서버의 경우에는 iconv.so까지 찾을수가 없어서 다음과 같이 정의했다.
export LD_LIBRARY_PATH=/usr/local/mysql/lib/:/usr/local/src/libiconv-1.14/lib/.libs/:$LD_LIBRARY_PATH





Thursday, September 11, 2014

Ubuntu MySQL API 설치

1. mysql 클라이언트 설치:
The program 'mysql' is currently not installed. You can install it by typing:
sudo apt-get install mysql-client-core-5.5

2. mysql 서버 설치:
sudo apt-get install mysql-server

3. mysql 라이브러리 설치:
sudo apt-get install libmysqlclient15-dev

CentOS MySQL API 설치

yum -y install mysql
yum -y install mysql-server
yum -y install mysql-devel

chgrp -R mysql /var/lib/mysql
chmod -R 770 /var/lib/mysql

service mysqld start

// libmysqlclient 설치
yum whatprovides "*libmysqlclient*"

Wednesday, September 10, 2014

Ubuntu Apache PHP MySQL 설치

0. 서버 URL 업데이트
sudo apt-get update

1. 아파치 서버 설치
sudo apt-get install apache2

2. MySQL 인증 모듈 설치
sudo apt-get install libapache2-mod-auth-mysql

3. MySQL 서버/클라이언트 설치
sudo apt-get install mysql-server mysql-client

4. PHP 설치
sudo apt-get install php5 php5-cli curl memcached php5-curl php5-gd php5-memcache php5-mysql php-apc php5-xsl php5-imap libssh2-php libapache2-mod-php5 php5-gd php5-xmlrpc php5-intl

5. 아파치 서버 재시작
sudo /etc/init.d/apache2 restart

6. 작동 상태 확인 (Check to see if it works)
sudo netstat -tap | grep mysql

올바르게 작동된다면 "LISTEN" 이라는 문구가 뜹니다
그렇지 않다면, mysql을 재시작해주세요.

sudo /etc/init.d/mysql restart

7. 아파치 및 MySQL 디폴트 디렉토리
Apache configuration: /etc/apache2/apache2.conf
Apache root location: /etc/apache2/sites-available/default
MySQL configuration: /etc/mysql/my.cnf
Default Web root: /var/www

Ubuntu MySQL 한글 설정

우분투에서 기본적으로 한글이 설정 안되어 있어서 한글을 입력하면 깨진다.
사용한 우분투 버전은 12.04 64비트 버전이다.

MySQL 접속을 위해 다음과 같이 입력하자.
mysql -u root -p
[암호입력]
status 명령어를 입력하여 보면 다음과 같이 입력되어 있을 것이다.
이렇게 되어 있으면 한글이 안된다.
Server characterset: latin1
Db characterset: latin1
따라서 MySQL 설정을 편집해 줘야 하는데 설정파일은 /etc/mysql/my.cnf이다.
먼저 파일을 복사하고 시작하자.
sudo cp /etc/mysql/my.cnf /etc/mysql/my.cnf.org
sudo gedit(or vi) /etc/mysql/my.cnf
# client 부분밑에 추가
[client]
default-character-set = utf8
# mysqld 부분밑에 추가
[mysqld]
init_connect = SET collation_connection = utf8_general_ci
init_connect = SET NAMES utf8
character-set-server = utf8
collation-server = utf8_general_ci
# mysqldump 부분밑에 추가
[mysqldump]
default-character-set = utf8
# mysql 부분밑에 추가
[mysql]
default-character-set = utf8
이제 파일을 저장했으니 mysql을 재시작하자.
인터넷에 돌아다니는 자료를 보면 각 리눅스나 설정마다 다른데 우분투의 경우는 다음과 같이 해결했다.
sudo /etc/init.d/mysql restart
다시 mysql -u root -p를 해서 status에서 Server와 Db characterset이 utf8이 나오면 성공이다.