一、在Mac上手工安裝方法
1、解壓tar文件
確定好mysql主目錄,并在主目錄中創(chuàng)建數(shù)據(jù)目錄和配置文件目錄和服務(wù)日志目錄
解壓mysql-5.7.10-osx10.9-x86_64.tar -> ~/mysql-5.7.10/
mkdir -p data log
cd ~/mysql-5.7.10/bin
2、初始化安裝,記住初始化密碼
./mysqld --console --initialize --basedir=~/mysql-5.7.10 --datadir=~/mysql-5.7.10/data
3、安裝完后可以啟動(dòng)服務(wù)
./mysqld --console --user=root --basedir=~/mysql-5.7.10 --datadir=~/mysql-5.7.10/data
4、修改初始化密碼
初始化后第一次使用前,要對(duì)數(shù)據(jù)庫(kù)進(jìn)行修改密碼:
ALTER USER 'root'@'localhost' IDENTIFIED BY '111111';
flush privileges;
5、遠(yuǎn)程訪問的問題
啟動(dòng)mysql服務(wù)
./mysqld --console
登錄
mysql -u root -p
查詢mysql 用戶表和對(duì)應(yīng)的host
use mysql;
select user, host from user;
將root用戶的host設(shè)為%
update user set host ='%' where user ='root';
?
6、配置快捷命令:
1.
vi ~/.bash_profile
2.
export MYSQL=~/mysql-5.7.10
export MYSQLSUPPORT=$MYSQL/support-files
export PATH=$MYSQL/bin:$MYSQLSUPPORT:$PATH
3.
source ~/.bash_profile
4.
修改mysql/support-files/mysql.server:
mysqld_pid_file_path=
if test -z "$basedir"
then
basedir=~/mysql-5.7.10
bindir=~/mysql-5.7.10/bin
# basedir=/usr/local/mysql
# bindir=/usr/local/mysql/bin
if test -z "$datadir"
then
datadir=~/mysql-5.7.10/data
# datadir=/usr/local/mysql/data
fi
sbindir=~/mysql-5.7.10/bin
libexecdir=~/mysql-5.7.10/bin
# sbindir=/usr/local/mysql/bin
# libexecdir=/usr/local/mysql/bin
5.
命令行啟動(dòng): mysql.server start
命令行關(guān)閉: mysql.server stop
?
7、配置文件
創(chuàng)建my.cnf和mysql.sock文件
[mysql]
default-character-set=utf8mb4
[mysqld]
#Mysql服務(wù)器對(duì)應(yīng)的端口;
port=3306
#Mysql安裝的絕對(duì)路徑;
basedir=~/mysql-5.7.10
#Mysql數(shù)據(jù)存放的絕對(duì)路徑;
datadir=~/mysql-5.7.10/data
#套接字文件
socket = ~/mysql-5.7.10/mysql.sock
#mysql中plugin插件所在的路徑;
plugin_dir = ~/mysql-5.7.10/lib/plugin
#mysql生成的錯(cuò)誤日志存放的路徑
log-error = ?~/mysql-5.7.10/log/error.log
# 服務(wù)端使用的字符集默認(rèn)為8
character-set-server=utf8
# 創(chuàng)建新表時(shí)將使用的默認(rèn)存儲(chǔ)引擎
default-storage-engine=INNODB
# 允許最大連接數(shù)
max_connections=100
collation-server=utf8_unicode_ci
init_connect='SET NAMES utf8'
innodb_buffer_pool_size=64M
innodb_flush_log_at_trx_commit=1
innodb_lock_wait_timeout=120
innodb_log_buffer_size=4M
innodb_log_file_size=256M
interactive_timeout=120
join_buffer_size=2M
key_buffer_size=32M
log_error_verbosity=1
max_allowed_packet=16M
max_heap_table_size=64M
myisam_max_sort_file_size=64G
myisam_sort_buffer_size=32M
read_buffer_size=512kb
read_rnd_buffer_size=4M
server_id=1
skip-external-locking=on
sort_buffer_size=256kb
table_open_cache=256
thread_cache_size=16
tmp_table_size=64M
wait_timeout=120
[client]
default-character-set=utf8mb4
?
二、在win10上手工安裝
1、安裝初始化
mysqld --initialize --console
啟動(dòng)
mysqld --console
登錄
mysql -u root -p
?
2、配置文件
my.ini
[client]
# 設(shè)置mysql客戶端默認(rèn)字符集
default-character-set=utf8mb4
[mysqld]
# 設(shè)置3306端口
port = 3306
# 設(shè)置mysql的安裝目錄
basedir=D:\soft\mysql-8.0.28
# 設(shè)置 mysql數(shù)據(jù)庫(kù)的數(shù)據(jù)的存放目錄,MySQL 8+ 不需要以下配置,系統(tǒng)自己生成即可,否則有可能報(bào)錯(cuò)
datadir=D:\soft\mysql-8.0.28\data
# 允許最大連接數(shù)
max_connections=20
# 服務(wù)端使用的字符集默認(rèn)為8比特編碼的latin1字符集
character-set-server=utf8
# 創(chuàng)建新表時(shí)將使用的默認(rèn)存儲(chǔ)引擎
default-storage-engine=INNODB
# skip-grant-tables
?
本文摘自 :https://www.cnblogs.com/