mysql8.0.20 安装 详解

# 下载 官网地址:https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz

################清理原有mysql环境#######################
rpm -qa | grep -i mysql | xargs yum remove -y
rpm -qa | grep -i mariadb | xargs yum remove -y
find / -name mysql | xargs rm -rf
################清理原有mysql环境######################

###########################解压文件比较耗时间######################
tar -xvf mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
###########################解压文件比较耗时间######################


##################第一步复制下面所有#####################
#移动文件重命名
mv mysql-8.0.20-linux-glibc2.12-x86_64 /usr/local/mysql

#添加用户组
cat /etc/group | grep mysql
cat /etc/passwd |grep mysql
groupadd mysql
useradd -r -g mysql mysql


# 创建文件夹
mkdir /usr/local/mysql/data

# 给文件夹授权
chown -R root:root /usr/local/mysql
# 给文件夹授权
chown -R mysql:mysql /usr/local/mysql/data/
# 初始化数据库,mysql的bin目录下的mysqld命令
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

##################第一步复制上面所有#####################

 

 

####完成之后看到 最后一行
####2021-03-28T05:48:33.232241Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: =vd(4KS6kpic
#得到初始化密码 =vd(4KS6kpic

 

# 检测命令 可忽略
rpm -qa|grep libaio
#
yum install libaio-devel.x86_64
#
yum -y install numactl

# 检测命令 可忽略

 


#配置mysql启动文件
touch /usr/local/mysql/support-files/my-default.cnf
chmod 777 /usr/local/mysql/support-files/my-default.cnf
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
vi /etc/my.cnf

#############################执行完上面的后 已经进入了my.cnf文件里面 直接复制下面内容########
[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket = /tmp/mysql.sock
log-error = /usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
port = 3306
#lower_case_table_names = 1
# server_id = .....
# socket = .....
#lower_case_table_names = 1
max_allowed_packet=32M
default-authentication-plugin = mysql_native_password
#lower_case_file_system = on
#lower_case_table_names = 1
log_bin_trust_function_creators = ON
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

 

#############################执行完上面的后 已经进入了my.cnf文件里面 直接复制上面内容########

#####my.cnf配置完成

 


# 设置开机启动数据库
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
# 设置开机启动数据库


#注册
chkconfig --add mysql
#检测
chkconfig --list mysql

 


#配置ld.so.conf 添加如下内容 /usr/local/mysql/lib
# 打开文件ld.so.conf命令:
vi /etc/ld.so.conf

# 添加如下内容加入配置文件ld.so.conf:
/usr/local/mysql/lib

 


# 配置环境变量 打开profile文件
vi /etc/profile

# 添加如下内容:
# MYSQL ENVIRONMENT
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib

# 系统重新加载文件,记得一定要
source /etc/profile

#启动mysql
service mysql start

#连接数据库
mysql -uroot -p
#输入密码

###################数据库mysql>里面操作
#修改密码
alter user ‘root‘@‘localhost‘ identified by ‘12345678‘;

#开放远程连接
use mysql;
update user set host = ‘%‘ where user = ‘root‘;
flush privileges;
#navicat可以连接了

 

mysql8.0.20 安装 详解

上一篇:photoshop设计打造出逼真的漂亮坦克游戏界面


下一篇:sqlplus命令行登录oracle数据库的几种方法