Skip to content

Instantly share code, notes, and snippets.

@hoangnamitc
Last active May 18, 2024 03:49
Show Gist options
  • Save hoangnamitc/10d0d6af6f192e9f71350fe4538f3036 to your computer and use it in GitHub Desktop.
Save hoangnamitc/10d0d6af6f192e9f71350fe4538f3036 to your computer and use it in GitHub Desktop.
Mysql

Cài đặt thông qua Brew (Yêu cầu cài Brew trước)

brew update
brew install mariadb

#LUÔN KHỞI ĐỘNG CÙNG MÁY https://mariadb.com/kb/en/launchd/


Khởi động

brew services start mariadb

Hoặc

mysql.server start

Xóa Pass Root:

sudo /usr/local/bin/mysql_secure_installation

hoặc

sudo mysql_secure_installation
<enter>

unix_socket: n

Change the root password? [Y/n] n

Remove anonymous users? [Y/n] y

Disallow root login remotely? [Y/n] y

Remove test database and access to it? [Y/n] y

Reload privilege tables now? [Y/n] y
mysql
SET PASSWORD FOR 'root'@localhost = PASSWORD("");

Stop

brew services stop mariadb

Để cài được Navicat trong bigSur cần cài thêm (bắt buộc):

brew install postgresql

Bỏ ràng buộc kiểu dữ liệu

  • mở file:
/usr/local/etc/my.cnf

Thêm dòng:

[mysqld]
sql_mode = "NO_ENGINE_SUBSTITUTION"

Nơi lưu trữ DB

/usr/local/var/mysql

Lỗi "limit open file"

kiểm tra bằng cách chạy SQL Query (default: 256):

SHOW VARIABLES LIKE 'open%'

mở file:

/usr/local/etc/my.cnf

Thêm dòng sau vào:

[mysqld]
open_files_limit = 5000
brew services stop mariadb
mkdir /usr/local/var/run/mysqld

Sửa file: /usr/local/etc/my.cnf:

[client-server]

[mysqld_safe]
pid-file = /usr/local/var/run/mysqld/mysqld.pid

Khởi động lại:

brew services start mariadb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment