Mysql

wwiki
이동: 둘러보기, 검색

참고: 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';