Mysql8.0.34 tar包安装

Mysql8.0.34 tar包安装

前提

下载地址:https://downloads.mysql.com/archives/community/

解压文件:tar -xvf mysql-8.0.34-linux-glibc2.12-x86\_64.tar.xz 

mv mysql-8.0.34-linux-glibc2.12-x86\_64 mysql

cp -r mysql /usr/local/

增加mysql用户和组

#增加mysql组 
groupadd mysql 
#增加mysql用户 
useradd -g mysql mysql

创建必要的目录

#mysql数据目录
mkdir /usr/local/mysql/data

#mysql日志目录
mkdir /usr/local/mysql/logs

#mysql 建立连接时存放.sock 文件的目录
mkdir /var/lib/mysql

#在logs目录创建日志文件
touch mysql.log

#修改目录权限为mysql
chown -R mysql\:mysql /usr/local/mysql
chown -R mysql\:mysql /var/lib/mysql

Mysql配置文件

vi /etc/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

[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 the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# 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
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password

datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
sql_mode=STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITut

log-error=/usr/local/mysql/logs/mysql.log
pid-file=/usr/local/mysql/logs/mysql.pid
#设置不区分大小写
lower_case_table_names=1

修改可读可写权限

chown -R mysql:mysql /etc/my.cnf 
chmod 644 /etc/my.cnf

初始化mysql

到bin目录下执行如下命令


./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

查看Mysql初始密码

cat …/logs/mysql.log\

2023-08-02T03:06:29.945123Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: #av#uKKsG0tr

复制mysql.server 到 /etc/init.d 目录下

cp support-files/mysql.server /etc/init.d/mysql

启动Mysql

service mysql start

配置环境变量

vi /etc/profilevi
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
source /etc/profile

进入Mysql,使用初始密码,并修改密码

mysql -uroot -p 
修改密码
#如果报错使用下面这条修改语句
alter user 'root'@'localhost' identified by 'Abc123' ;

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Abc123';

修改其他ip地址可以连接本机mysql

use mysql;
update user set host='%' where user = 'root';
flush privileges;

#如果报错使用下面这条修改语句
alter user 'root'@'%' identified with mysql_native_password by 'Abc123';
ALTER USER 'root'@'%' IDENTIFIED BY 'Abc123';

flush privileges;
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值