SELECT order_id,product_name,qty
FROM orders
INTO OUTFILE '/tmp/orders.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
* Access deniey 발생 시
ERROR 1045 (28000): Access denied for user 'user1'@'localhost' (using password: YES)
GRANT FILE ON *.* TO 'kccfres'@'localhost';
* secure-file-priv 처리
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
1. Mysql client 로 연결후 SHOW variable 로 MySQL 환경 변수 확인
mysql> SHOW VARIABLES LIKE "secure_file_priv";
+------------------+-----------------------+
| Variable_name | Value |
+------------------+-----------------------+
| secure_file_priv | /var/lib/mysql-files/ |
+------------------+-----------------------+
1 row in set (0.02 sec)
2. INTO OUTFILE 의 저장 경로를 위의 secure_file_priv 폴더로 변경
INTO OUTFILE '/tmp/orders.csv' → INTO OUTFILE '/var/lib/mysql-files/orders.csv'
3. 쿼리 재실행
2. DB 접속하지 않은 상태에서 실행
mysql -user -pass -e "select cols from orders" dbname > /tmp/orders.csv
//리모트인 경우
mysql -h {아이피} -user -pass -e "select cols from orders" dbname > /tmp/orders.csv
<script>
// 테이블의 Row 클릭시 값 가져오기
$("#example-table-1 tr").click(function(){
var str = ""
var tdArr = new Array(); // 배열 선언
// 현재 클릭된 Row(<tr>)
var tr = $(this);
var td = tr.children();
// tr.text()는 클릭된 Row 즉 tr에 있는 모든 값을 가져온다.
console.log("클릭한 Row의 모든 데이터 : "+tr.text());
// 반복문을 이용해서 배열에 값을 담아 사용할 수 도 있다.
td.each(function(i){
tdArr.push(td.eq(i).text());
});
console.log("배열에 담긴 값 : "+tdArr);
// td.eq(index)를 통해 값을 가져올 수도 있다.
var no = td.eq(0).text();
var userid = td.eq(1).text();
var name = td.eq(2).text();
var email = td.eq(3).text();
str += " * 클릭된 Row의 td값 = No. : <font color='red'>" + no + "</font>" +
", 아이디 : <font color='red'>" + userid + "</font>" +
", 이름 : <font color='red'>" + name + "</font>" +
", 이메일 : <font color='red'>" + email + "</font>";
$("#ex1_Result1").html(" * 클릭한 Row의 모든 데이터 = " + tr.text());
$("#ex1_Result2").html(str);
});
</script>
//1일 추가
> tmpdate = new Date(2021,07,07)
Sat Aug 07 2021 00:00:00 GMT+0900 (한국 표준시)
> tmpdate.setTime(tmpdate.getTime() + (24*60*60*1000))
1628348400000
> new Date(tmpdate)
Sun Aug 08 2021 00:00:00 GMT+0900 (한국 표준시)
//1시간 추가
> tmpdate = new Date(2021,07,07)
Sat Aug 07 2021 00:00:00 GMT+0900 (한국 표준시)
> tmpdate.setTime(tmpdate.getTime() + (1*60*60*1000))
1628265600000
> new Date(tmpdate)
Sat Aug 07 2021 01:00:00 GMT+0900 (한국 표준시)
포멧 변경
function sDateToDate(strDate)
{
//Ex) '04/26/2021 4:37 PM'
var yyyyMMDD = String(strDate)
var sYear = yyyyMMDD.substring(6,10);
var sMonth = yyyyMMDD.substring(0,2);
var sDate = yyyyMMDD.substring(3,5);
var sTime = yyyyMMDD.substring(10,19);
//Ex) '2021-04-26 4:37 PM'
return sYear + '-' + sMonth + '-' + sDate + sTime
}
일반적으로 사용되는 그레고리안 달력(Gregorian Calendar)의 년,월,일을 나타냄
datetime.time
시간을 시,분,초,마이크로초,시간대(Time zone)로 나타냄
datetime.datetime
date클래스와time클래스의 조합으로 년,월,일,시,분,초,마이크로초,시간대 정보를 나타냄
datetime.timedelta
두 날짜 혹은 시간 사이의 기간을 표현
datetime.date 클래스
datetime.date클래스는 일반적으로 사용되는 년,월,일로 표기되는 그레고리안 달력의 날짜를 표현함
생성자: datetime.date(year, month, day)
숫자로 년,월,일을 입력받아서date객체를 생성
- year :1 ~ 9999
- month :1 ~ 12
- day :1 ~해당월의 마지막 날짜
>>> import datetime
>>> D=datetime.date(2013,2,18)
>>> D
datetime.date(2013, 2, 18)
>>> print(D)
2013-02-18
>>> D=datetime.date(2013,2,31) #해당월의 최대일수를 넘으면 ValueError발생
Traceback (most recent call last):
File "<pyshell#194>", line 1, in <module>
D=datetime.date(2013,2,31)
ValueError: day is out of range for month
생성된timedelta객체를 이용하여date, datetime객체를 변경할수 있다.지원하는 연산은 아래와 같으며,각 객체간의 비교연산도 가능하다.
- date_2 = date_1 + timedelta
- date_2 = date_1 - timedelta
- timedelta = date_2 - date_1
- datetime_2 = datetime_1 + timedelta
- datetime_2 = datetime_1 - timedelta
- timedelta = datetime_1 - datetime_2
>>> from datetime import timedelta, date
>>> d = date.today()
>>> d
datetime.date(2013, 3, 29)
>>> td=timedelta(days=3) #timedelta를 3일로 설정
>>> d + td #오늘로부터 3일 후
datetime.date(2013, 4, 1)
>>> d - td #오늘로부터 3일 전
datetime.date(2013, 3, 26)
두date객체 사이의 기간(timedelta)을 구하기 위해서는 아래와 같이'-'연산으로 측정가능하며, date객체간의 비교연산도 가능하다.
>>> from datetime import timedelta, date
>>> d = date.today()
>>> d2 = d.replace(day=20)
>>> d2
datetime.date(2013, 3, 20)
>>> dt = d - d2
>>> dt
datetime.timedelta(9)
>>> d2 > d
False
2. services.msc에 Remote Registry가 시작되었는지 체크 3. unlodctr 와 lodctr 을 이용해서 SQL 관련 카운터를 다시 등록할것
1) cmd(Administrator권한으로)
2) SQL SERVER의 binn폴더로 이동
3)unlodctr을 이용해서 SQL counters를 unload한다.
e.g. unlodctr MSSQLSERVER (for default instance)
e.g. unlodctr SQLSERVERAGENT (for default SQL Agent)
e.g. unlodctr MSSQL$TEST (for named instance)
e.g. unlodctr SQLAGENT$TEST (for SQL agent)
4)lodctr을 이용해서 SQL counters를 다시 등록한다.
e.g. lodctr perf-MSSQLSERVERsqlctr.ini (for default instance)
e.g. lodctr perf-SQLSERVERAGENTsqlagtctr.ini (for default SQL Agent)
e.g. lodctr perf-MSSQL$TESTsqlctr.ini (for named instance)
e.g. lodctr perf-SQLAGENT$TESTsqlagtctr.ini (for SQL Agent)
5)Remote Registry service를 다시 시작한다.
net stop "Remote Registry"
net start "Remote Registry"
6)필요할 경우 WMI와 WinPrivSE.exe 싱크를 다시 맞춘다.
e.g. winmgmt /resyncperfctr "5660"
cf)5660은 WinPrivSE.exe 의 pid
4. performance counter를 재등록 한다.
lodctr /R --> 모든
주의!!! 모든 performance counter registry 세팅을 재등록하게 된다.
-- 계정 생성
insert into user(host, user, authentication_string, ssl_cipher, x509_issuer, x509_subject)
values('%', 'account_srv', password('StrongPassword'), '', '', '');
--권한
grant all privileges on *.* to 'account_srv'@'%' identified by 'StrongPassword' with grant option;
grant select, insert, update, delete, execute on *.* to 'account_srv'@'%' identified by 'StrongPassword' with grant option;
flush privileges;
--- 비밀 번호 변경
UPDATE mysql.user SET Password=PASSWORD('StrongPassword') WHERE User='account_srv' AND Host='%';
SET PASSWORD FOR 'account_srv'@'%' = PASSWORD('StrongPassword');
ALTER USER 'account_srv'@'%' identified by 'StrongPassword';
flush privileges;
-- 권한 확인
# show grants for 'user'@'접속위치';
show grants for 'account_srv'@'%';
-- 계정 삭제
# drop user '계정아이디'@'접속위치';
drop user 'account_srv'@'%';
-- 권한 삭제
# revoke all on DB이름.테이블 FROM '계정아이디'@'접속위치';
revoke all on *.* FROM 'account_srv'@'%';
Version - 8.0
-- 사용자 정보 조회
SELECT user,authentication_string,plugin,host FROM mysql.user;
-- 사용자 생성
create user 'account_srv'@'%' identified by 'StrongPassword';
-- 권한 부여
GRANT ALL PRIVILEGES ON *.* TO 'account_srv'@'%';
GRANT GRANT OPTION ON *.* TO 'account_srv'@'%';
-- 비밀번호 plugin 변경
ALTER USER 'account_srv'@'%' IDENTIFIED WITH mysql_native_password BY 'StrongPassword';