All posts

IT

기존 DB 백업하기

// 전체 DB 백업
# mysqldump -u[유저명] -p -A > [파일명]
# mysqldump -uuser1 -p -A > Backup_DB_`date +%y%m%d`.sql

// 특정 DB 백업
# mysqldump -u[유저명] -p [DB명] > [파일명]
# mysqldump -uuser1 -p Service1 > Backup_DB_Service1_`date +%y%m%d`.sql

 

 

DB 구성하기

더보기

 

MariaDB 설치 및 서비스 등록

// 관련 패키지 설치
 # yum install mariadb mariadb-server -y

// 패키지 설치 여부 확인
 # mysql --version
 # systemctl status mariadb

// 서비스 시작
 # systemctl start mariadb
 # systemctl status mariadb

// 서비스 자동 시작 활성화
 # systemctl enable mariadb

 

DB 접근하기

// root 패스워드 설정하기
 # mysqladmin -u root password '[비밀번호]'
 # mysqladmin -u root password 'passwd'

// MariaDB 접속
 # mysql -u root -p
  Enter password: [비밀번호]

 

DB 생성 및 권한 부여

// DB 생성
 > CREATE DATABASE [DB명];
 > CREATE DATABASE Service1;
 
// DB 로컬 유저 생성
 > CREATE USER '[유저명]'@'localhost' IDENTIFIED BY '[비밀번호]';
 > CREATE USER 'user1'@'localhost' IDENTIFIED BY 'passwd';

// DB 권한 부여
 > GRANT ALL PRIVILEGES ON [DB명].* TO '[유저명]'@'localhost';
 > GRANT ALL PRIVILEGES ON Service1.* TO 'user1'@'localhost';
 
 > exit

 

 

DB 덮어쓰기(복원)

// 전체 DB 복원
 # mysql -u[유저명] -p < [백업파일]
 # mysql -uroot -p < Backup_DB_`date +%y%m%d`.sql

// 특정 DB 복원
 # mysql -u[유저명] -p [DB명] < [백업파일]
 # mysql -uroot -p Service1 < Backup_DB_Service1_`date +%y%m%d`.sql

 

반응형

CMD에서 현재 페이지 코드를 변경해도 CMD를 다시 킬 경우 설정 값이 초기화 된다.

이런 경우 레지스트리를 이용하여 자동으로 변경되게끔 해주면 된다.

 

1. [실행] - 'regedit' - HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor

2. [새로 만들기] - [문자열 값]

3. 레지스트리 생성 - 이름: Autorun / 값: chcp 437 & cls

 

이제 CMD를 실행하면, 원하는 코드 값으로 변경된 것을 확인할 수 있다.

 

 

현재 페이지 코드 확인하기

> chcp

 

명령줄로 설정하기

> reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor" /v Autorun /d "chcp 437 & cls" /f

 

 

반응형

connect() to unix:/var/run/php-fpm/php-fpm.sock failed (2: No such file or directory)

2020/08/14 10:05:46 [crit] 8538#0: *2 connect() to unix:/var/run/php-fpm/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: [my_IP_address], server: [my_domain], request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "[my_domain]:82"
2020/08/14 10:05:46 [error] 8538#0: *2 open() "/var/www/html/wordpress/nginx-logo.png" failed (2: No such file or directory), client: [my_IP_address], server: [my_domain], request: "GET /nginx-logo.png HTTP/1.1", host: "[my_domain]:82", referrer: "http://[my_domain]:82/"
2020/08/14 10:05:46 [error] 8541#0: *1 open() "/var/www/html/wordpress/poweredby.png" failed (2: No such file or directory), client: [my_IP_address], server: [my_domain], request: "GET /poweredby.png HTTP/1.1", host: "[my_domain]:82", referrer: "http://[my_domain]:82/"

I had to integrate websites that used Nginx and php into other web servers. This content describes the process of resolving errors that occurred during Web server consolidation.

 

 

First, I checked the versions of Nginx and php.

Before integrating the web server, I matched the same version of Nginx and php. However, when I checked the php version, php was activating the existing version, and I upgraded the version in a new way.

 

How to upgrade PHP version:

The same version of Nginx and php were matched, but the same error occurred. So I reinstalled php-fpm. But the result was same.

// Check package name
# yum list php*fpm

// Remove
# yum remove php70w-fpm -y

// Reinstall
# yum install php70w-fpm -y

 

And I check the path of php-fpm again,

 

NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)

I've just recently moved my websites from apache2 to Nginx as my new web server backend. got to love problems aha. HTML files in the web host director work prior to php files making there way main

stackoverflow.com

 

Finally, it was resolved through LISTEN value modification and permission setting.

/etc/php-fpm.d/www.conf

[www]
;user = apache
user = nginx
;group = apache
group = nginx

;listen = 127.0.0.1:9000
listen = /var/run/php-fpm/php-fpm.sock

;listen.owner = nobody
listen.owner = nginx
;listen.group = nobody
listen.group = nginx
listen.mode = 0660
# systemctl restart nginx php-fpm
 

Permission Denied for fastcgi_pass using PHP7

I'm running LEMP with PHP7.0. I've got this in my server block fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; But when I open the site, it returns a 502 Bad Gateway. Below is the error log. *1

serverfault.com

 

NGINX: connect() to unix:/var/run/php-fpm.sock failed (2: No such file or directory) – The new polyglot

This website uses cookies. If you continue to use this site we will assume that you are happy with this. Accept

www.the-new-polyglot.co.uk

 

반응형

1) Check the existing php version.

# php -v

 

2) Remove existing php.

# yum remove php-*
# yum remove php-common mod_php php-cli

 

3) Upgrade the php installation package

# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

# yum --enablerepo=remi update remi-release

 

4) Install php and related packages

# yum install php70w

# yum install php70w-cli php70w-common php70w-dba php70w-devel php70w-fpm php70w-gd php70w-imap -y
# yum install php70w-ldap php70w-mbstring php70w-mcrypt php70w-mysqlnd php70w-odbc php70w-opcache -y
# yum install php70w-pdo php70w-pdo_dblib php70w-pear php70w-pecl-imagick php70w-pecl-imagick-devel -y 
# yum install php70w-pgsql php70w-phpdbg php70w-process php70w-snmp php70w-soap php70w-tidy php70w-xml php70w-xmlrpc -yHTML 

 

5) Check the current php version.

# php -v

반응형

전체 DB 목록 조회

SELECT name FROM master.dbo.sysdatabases

 

DB별 계정 및 역할(Role) 조회

SELECT
	[UserName] = CASE memberprinc.[type] 
		WHEN 'S' THEN memberprinc.[name]
		WHEN 'U' THEN ulogin.[name] COLLATE Latin1_General_CI_AI
		END,   
	[Role] = roleprinc.[name]
FROM 
	sys.database_role_members members
JOIN
	sys.database_principals roleprinc ON roleprinc.[principal_id] = members.[role_principal_id]
JOIN
	sys.database_principals memberprinc ON memberprinc.[principal_id] = members.[member_principal_id]
LEFT JOIN
	sys.login_token ulogin on memberprinc.[sid] = ulogin.[sid]

 

여러 방법을 이용하여 DB별 계정과 역할을 한 번에 조회하려고 했으나 모두 실패했다.

일단, 'USE' 에서 변수 사용이 되지 않아서 배열, 프로시저, 임시 테이블 등의 방법을 사용해도 제대로 작동하지 않는다.

 

결국에는 DB 전체 목록을 출력해서 조회 했다.

 

참고 사이트: 

 

SQL Server query to find all permissions/access for all users in a database

I would like to write a query on a sql 2008 that will report all the users that have access to a specific database, or objects within the database such as tables, views, and stored procedures, either

stackoverflow.com

 

 

반응형