"Mysql"의 두 판 사이의 차이
(→설정파일을 수정) |
|||
(같은 사용자의 중간 판 18개는 보이지 않습니다) | |||
1번째 줄: | 1번째 줄: | ||
+ | 참고: [[MariaDB]] | ||
+ | |||
===서비스 상태 확인=== | ===서비스 상태 확인=== | ||
systemctl status mysql | systemctl status mysql | ||
12번째 줄: | 14번째 줄: | ||
bind-address = 0.0.0.0 | bind-address = 0.0.0.0 | ||
− | ===사용자 보기=== | + | ===사용자=== |
+ | ====보기==== | ||
> use mysql; | > use mysql; | ||
> select host, user, password from user; | > select host, user, password from user; | ||
− | === | + | ====추가==== |
− | + | CREATE USER 'newuser'@'%' IDENTIFIED BY 'user_password'; | |
− | + | ===데이터베이스 사용권한=== | |
− | === | + | ====권한부여==== |
> grant all privileges on [database].* to [user]@'192.168.0.%' identified by '[password]'; | > grant all privileges on [database].* to [user]@'192.168.0.%' identified by '[password]'; | ||
− | ===변경된 권한 | + | =====변경된 권한 적용===== |
> flush privileges; | > flush privileges; | ||
+ | |||
+ | ====권한 확인==== | ||
+ | > show grants ; | ||
+ | |||
+ | ====권한 삭제==== | ||
+ | > revoke all on [database].[table] from [user]@host; | ||
+ | |||
+ | [table]<!-- 테이블명 -->은 생략가능 | ||
===Barracuda format변경=== | ===Barracuda format변경=== | ||
51번째 줄: | 62번째 줄: | ||
====설정 수정==== | ====설정 수정==== | ||
− | set global innodb_large_prefix = ON; | + | > set global innodb_large_prefix = ON; |
+ | |||
+ | > set global innodb_file_format = BARRACUDA; | ||
+ | ====Create Table 옵션추가==== | ||
+ | > CREATE TABLE [table_name] ( | ||
+ | |||
+ | `Id` varchar(767) NOT NULL, | ||
+ | |||
+ | `Name` varchar(256) NULL, | ||
+ | |||
+ | `NormalizedName` varchar(256) NULL, | ||
+ | |||
+ | `ConcurrencyStamp` text NULL, | ||
+ | |||
+ | PRIMARY KEY (`Id`) | ||
+ | |||
+ | )'''ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC'''; | ||
+ | |||
+ | ==GUI Tool== | ||
+ | <nowiki>#</nowiki> arm base | ||
+ | |||
+ | docker run --name myadmin -d -e PMA_HOST=dbhost -p 8080:80 ebspace/armhf-phpmyadmin | ||
+ | |||
+ | <nowiki>http://your_host_ip:8080/phpmyadmin</nowiki> | ||
+ | |||
+ | https://www.mysql.com/products/workbench/ | ||
+ | |||
+ | ==로그 설정== | ||
+ | $ mysql -su root | ||
+ | |||
+ | ===로그 설정보기=== | ||
+ | mysql> show variables like 'general_log%'; | ||
+ | |||
+ | mysql> set global general_log=on; | ||
+ | |||
+ | $ sudo nano /etc/my.cnf | ||
+ | |||
+ | [mysqld] | ||
+ | |||
+ | general_log_file = /var/log/general.log | ||
+ | |||
+ | general_log = 1 | ||
+ | |||
+ | ==백업 및 복구== | ||
− | + | [[MysqlDump]]를 사용하여 백업 및 복구를 할 수 있다. | |
− | ==== | + | ==타임존== |
+ | SET @@session.time_zone='+09:00'; | ||
+ | [[분류:Database]] |
2023년 2월 28일 (화) 01:15 기준 최신판
참고: MariaDB
목차
서비스 상태 확인[편집 | 원본 편집]
systemctl status mysql
MySQL monitor[편집 | 원본 편집]
# mysql -u root
> show databases;
외부아이피 접속 설정[편집 | 원본 편집]
# nano /etc/mysql/mariadb.conf.d/50-server.cnf
bind-address = 0.0.0.0
사용자[편집 | 원본 편집]
보기[편집 | 원본 편집]
> use mysql;
> select host, user, password from user;
추가[편집 | 원본 편집]
CREATE USER 'newuser'@'%' IDENTIFIED BY 'user_password';
데이터베이스 사용권한[편집 | 원본 편집]
권한부여[편집 | 원본 편집]
> grant all privileges on [database].* to [user]@'192.168.0.%' identified by '[password]';
변경된 권한 적용[편집 | 원본 편집]
> flush privileges;
권한 확인[편집 | 원본 편집]
> show grants ;
권한 삭제[편집 | 원본 편집]
> revoke all on [database].[table] from [user]@host;
[table]은 생략가능
Barracuda format변경[편집 | 원본 편집]
에러내용[편집 | 원본 편집]
Index column size too large. The maximum column size is 767 bytes.
위 에러가 나는 경우에 변경해 주어야 한다.
현재 포맷 확인[편집 | 원본 편집]
> use mysql;
> show variables like 'innodb_file_format';
+--------------------+----------+
| Variable_name | Value |
+--------------------+----------+
| innodb_file_format | Antelope |
+--------------------+----------+
설정 수정[편집 | 원본 편집]
> set global innodb_large_prefix = ON;
> set global innodb_file_format = BARRACUDA;
Create Table 옵션추가[편집 | 원본 편집]
> CREATE TABLE [table_name] (
`Id` varchar(767) NOT NULL,
`Name` varchar(256) NULL,
`NormalizedName` varchar(256) NULL,
`ConcurrencyStamp` text NULL,
PRIMARY KEY (`Id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
GUI Tool[편집 | 원본 편집]
# arm base
docker run --name myadmin -d -e PMA_HOST=dbhost -p 8080:80 ebspace/armhf-phpmyadmin
http://your_host_ip:8080/phpmyadmin
https://www.mysql.com/products/workbench/
로그 설정[편집 | 원본 편집]
$ mysql -su root
로그 설정보기[편집 | 원본 편집]
mysql> show variables like 'general_log%';
mysql> set global general_log=on;
$ sudo nano /etc/my.cnf
[mysqld]
general_log_file = /var/log/general.log
general_log = 1
백업 및 복구[편집 | 원본 편집]
MysqlDump를 사용하여 백업 및 복구를 할 수 있다.
타임존[편집 | 원본 편집]
SET @@session.time_zone='+09:00';