离线安装MySQL

离线安装mysql

[下载地址](MySQL :: Download MySQL Community Server)

执行命令 uname -m 查看服务器是什么架构,然后选择自己需要安装的版本

解压后依次执行如下命令

rpm -ivh mysql-community-common-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.31-1.el7.x86_64.rpm
  
# 如出现错误信息,则执行   rpm -ivh mysql-community-libs-8.0.31-1.el7.x86_64.rpm --nodeps --force
# --nodeps 不检查依赖关系
# --force 强制安装
rpm -ivh mysql-community-libs-8.0.31-1.el7.x86_64.rpm
  
rpm -ivh mysql-community-client-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.31-1.el7.x86_64.rpm
# 执行该命令若出现以下错误,说明与mariadb 包冲突
rpm -ivh mysql-community-server-8.0.31-1.el7.x86_64.rpm

[root@localhost local]# rpm -ivh mysql-community-server-8.0.31-1.el7.x86_64.rpm
warning: mysql-community-server-8.0.31-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Preparing... ################################# [100%]
file /etc/my.cnf from install of mysql-community-server-8.0.31-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.68-1.el7.x86_64

执行如下命令,卸载掉mariadb 冲突包,再次安装

mysql 初始化设置

# 设置开机自启动
systemctl enable mysqld
# 启动mysql
systemctl start mysqld
# 查看默认密码
grep 'temporary password' /var/log/mysqld.log
#登录mysql
mysql -uroot -p
  
mysql> use mysql  

# mysql8 开启远程连接方式用之前版本的命令是不可以的,要注意
mysql> create user root@'%' identified by '1234Qwer!@#$';  
  
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

mysql> flush privileges;

# 检查是否设置成功  
mysql> select host,user from user;  

一定要记得开启所需的端口号,烦死了

posted @ 2023-06-01 18:01  暮雨寒冬  阅读(172)  评论(0编辑  收藏  举报