【阿里云】在CentOS7系统上安装MySQL8
生活随笔
收集整理的這篇文章主要介紹了
【阿里云】在CentOS7系统上安装MySQL8
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
# 1、卸載MariaDB
## 1.1 查看版本
[~]~ rpm -qa|grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
## 1.2 卸載
[~]~ rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
## 1.3 檢查是否卸載干凈
[~]~ rpm -qa|grep mariadb# 2、安裝MySQL
[~]~ cd /home/
## 2.1 wget下載
[home]~ wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
。。。。。。
## 2.2 解壓
[home]~ tar -Jxvf mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
。。。。。。
## 2.3 重命名
[home]~ mv mysql-8.0.20-linux-glibc2.12-x86_64 mysql8
## 2.4 移除
[home]~ rm mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz # 3、用戶和用戶組
## 3.1 創(chuàng)建用戶組和用戶
# 創(chuàng)建一個(gè)用戶組:mysql
[home]~ groupadd mysql
# 創(chuàng)建一個(gè)系統(tǒng)用戶:mysql,指定用戶組為mysql
[home]~ useradd -r -g mysql mysql
## 3.2 數(shù)據(jù)目錄
# 1、創(chuàng)建目錄
[home]~ mkdir -p /home/mysql8/datas
# 2、賦予權(quán)限
# 更改屬主和數(shù)組
[home]~ chown -R mysql:mysql /home/mysql8/datas
# 更改模式
[home]~ chmod -R 750 /home/mysql8/datas
在mysql8文件夾中創(chuàng)建my.cnf文件,添加下面內(nèi)容
[mysql] # 默認(rèn)字符集 default-character-set=utf8mb4 [client] port = 3306 socket = /tmp/mysql.sock[mysqld] port = 3306 server-id = 3306 user = mysql socket = /tmp/mysql.sock # 安裝目錄 basedir = /home/mysql8 # 數(shù)據(jù)存放目錄 datadir = /home/mysql8/datas/mysql log-bin = /home/mysql8/datas/mysql/mysql-bin innodb_data_home_dir =/home/mysql8/datas/mysql innodb_log_group_home_dir =/home/mysql8/datas/mysql #日志及進(jìn)程數(shù)據(jù)的存放目錄 log-error =/home/mysql8/datas/mysql/mysql.log pid-file =/home/mysql8/datas/mysql/mysql.pid # 服務(wù)端使用的字符集默認(rèn)為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 = 65535binlog_format=mixedbinlog_expire_logs_seconds =864000# 創(chuàng)建新表時(shí)將使用的默認(rèn)存儲(chǔ)引擎 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 # 4、初始化MySQL ## 4.1 臨時(shí)環(huán)境變量,關(guān)閉shell后失效,通常用于測(cè)試環(huán)境 [home]~ export PATH=$PATH:/home/mysql8/bin ## 4.2 初始化 [home]~ mysqld_safe --defaults-file=/home/mysql8/my.cnf & ## 4.3 啟動(dòng)MySQL [home]~ mysql -uroot --skip-password # 5、MySQL操作 ## 5.1 修改密碼 mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456'; mysql> FLUSH PRIVILEGES;## 5.2 設(shè)置允許遠(yuǎn)程登錄 mysql> use mysql mysql> update user set user.Host='%'where user.User='root'; mysql> flush privileges; mysql> quit總結(jié)
以上是生活随笔為你收集整理的【阿里云】在CentOS7系统上安装MySQL8的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 计算机中常用的时间换算
- 下一篇: 什么是构建