1. Homebrew 를 이용하여 MariaDB 설치
https://mariadb.com/ko/resources/blog/installing-mariadb-10-1-16-on-mac-os-x-with-homebrew/
Installing MariaDB Server on Mac OS X with Homebrew | MariaDB
Developing on your Mac? Get the latest stable MariaDB version on OS X easily with Homebrew. See this step by step guide on installing MariaDB 10.4.13.
mariadb.com
나의 맥북에서는..
//탐색
brew update - brew 정보 업데이트
brew search mariadb 마리아 DB 찾아보기
brew info mariadb 마리아 DB 정보 보기
//설치
brew install mariadb
c@cgui-MacBookPro ~ % mysql_install_db
mysql.user table already exists!
Run mysql_upgrade, not mysql_install_db
c@cgui-MacBookPro ~ % mysql.server start
Starting MariaDB
. SUCCESS!
c@cgui-MacBookPro ~ % mysql
MariaDB [(none)]> exit
Bye
2. root 비밀번호 생성 하고 secure-install
c@cgui-MacBookPro ~ % mysql
MariaDB [(none)]> show databases;
MariaDB [(none)]> use mysql;
MariaDB [mysql]> set password for 'root'@'localhost' = PASSWORD(‘비밀번호');
MariaDB [mysql]> flush privileges;
MariaDB [mysql]> exit
c@cgui-MacBookPro ~ % mysql -u root -p
Enter password: 비밀번호입력
MariaDB [(none)]> exit
c@cgui-MacBookPro ~ % mariadb-secure-installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
.
.
.
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
3. Database, table 만들고 사용자 만들어 권한 주기
// root 로그인
c@cgui-MacBookPro ~ % mysql -u root -p
Enter password: root비밀번호
// create database
MariaDB [(none)]> create database test_db;
Query OK, 1 row affected (0.002 sec)
// use database
MariaDB [(none)]> use test_db;
Database changed
// create table
MariaDB [test_db]> CREATE TABLE `test_table` (
-> `date` text NOT NULL,
-> `id` varchar(15) NOT NULL,
-> `title` text NOT NULL,
-> `desc` text NOT NULL,
-> PRIMARY KEY (`id`)
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
Query OK, 0 rows affected (0.038 sec)
// table 확인
MariaDB [test_db]> show tables;
// ab 라는 user 만들고 비밀번호 생성
MariaDB [test_db]> create user 'ab'@'%' identified by 'ab의 비밀번호';
Query OK, 0 rows affected (0.010 sec)
// user 가 사용할 database에 권한 주기
MariaDB [test_db]> grant all privileges on test_db.* to 'ab'@'%';
Query OK, 0 rows affected (0.011 sec)
MariaDB [test_db]> exit
Bye
// ab 라는 user 로 접근하여 확인해 보기
c@cgui-MacBookPro ~ % mysql -u ab -p
Enter password: ab의 비밀번호
MariaDB [(none)]> use test_db;
Database changed
MariaDB [test_db]> select * from test_table;
Empty set (0.000 sec)
MariaDB [test_db]>
'Mac OS' 카테고리의 다른 글
[macOS] Ventura 단축키 찾아보기 (0) | 2022.11.19 |
---|