1.opt目录下创建一个install文件夹,并用iftp导入tar包
2.解压到/usr/local中
3.进入usr/local中,改mysq..的名字为mysql8
4.vim进入etc/profile中添加全局变量
5.创建组和对应的用户
6.在usr/local/mysql8中新建文件夹datas并赋予权限
7.mysql8文件夹下新家my.cnf文件并编辑
[mysql]
# 默认字符集
default-character-set=utf8mb4
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
server-id = 3306
user = mysql
socket = /tmp/mysql.sock
# 安装目录
basedir = /usr/local/mysql8
# 数据存放目录
datadir = /usr/local/mysql8/datas/mysql
log-bin = /usr/local/mysql8/datas/mysql/mysql-bin
innodb_data_home_dir =/usr/local/mysql8/datas/mysql
innodb_log_group_home_dir =/usr/local/mysql8/datas/mysql
#日志及进程数据的存放目录
log-error =/usr/local/mysql8/datas/mysql/mysql.log
pid-file =/usr/local/mysql8/datas/mysql/mysql.pid
# 服务端使用的字符集默认为8比特编码
character-set-server=utf8mb4
lower_case_table_names=1
autocommit =1
##################以上要修改的########################
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 1024
sort_buffer_size = 4M
net_buffer_length = 8K
read_buffer_size = 4M
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 64M
thread_cache_size = 128
#query_cache_size = 128M
tmp_table_size = 128M
explicit_defaults_for_timestamp = true
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535
binlog_format=mixed
binlog_expire_logs_seconds =864000
# 创建新表时将使用的默认存储引擎
default_storage_engine = InnoDB
innodb_data_file_path = ibdata1:10M:autoextend
innodb_buffer_pool_size = 1024M
innodb_log_file_size = 256M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
transaction-isolation=READ-COMMITTED
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 4M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
8.初始化
mysqld --defaults-file=/usr/local/mysql8/my.cnf --basedir=/usr/local/mysql8/ --datadir=/usr/local/mysql8/datas/mysql --user=mysql --initialize-insecure
10.启动mysql
10.1启动服务:
mysqld_safe --defaults-file=/usr/local/mysql8/my.cnf &
此时可通过
查看MySQL是否已经开启
10.2进入bin目录后无密码登录
10.3修改密码并刷新权限
此时就可以通过
登录MySQL了
10.4登录到mysql里,设置远程登陆
10.5此时就可以通过navicat远程连接mysql
11设置mysql自启动
在
目录下新建autostartmysql.sh并编辑赋予此文件+x 权限
最后设置开机自启
此时重启虚拟机,mysql就会自启动了