MySql教程

mysql安装部署

本文主要是介绍mysql安装部署,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1、环境准备

yum  -y install wget

2、mysql依赖包下载

wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-client-8.0.28-1.el7.x86_64.rpm
wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-devel-8.0.28-1.el7.x86_64.rpm
wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-embedded-compat-8.0.28-1.el7.x86_64.rpm
wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-libs-8.0.28-1.el7.x86_64.rpm
wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-libs-compat-8.0.28-1.el7.x86_64.rpm
wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-server-8.0.28-1.el7.x86_64.rpm
wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-common-8.0.28-1.el7.x86_64.rpm
wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm
wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm

3、安装 mysql

yum  -y  localinstall ./mysql-community-*

4、修改配置文件(更改数据存放路径)

#创建数据存放文件夹
mkdir /data/mysql -p

#修改mysql配置文件
grep -v -E '^#|^$' /etc/my.cnf
[mysqld]
port=3306
default-storage-engine=InnoDB
max_connections=1200
datadir=/data/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
log_slave_updates=ON
log_bin=mysql-bin
binlog_format=ROW

5、启动并加入开机自启

systemctl enable --now mysqld

6、修改密码

# grep password /var/log/mysqld.log
2022-04-13T07:31:54.168545Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: hBHJda&;a7PL

# mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY "Admin@123";

 

 
这篇关于mysql安装部署的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!