Linux(Centos 8.2) 使用RPM包安装Mysql8.0.20

1.准备所需的安装包:

应当按照common(依赖)–>libs(依赖)–>client(客户端)–>server(服务端)的顺序安装,否则安装过程会提醒依赖顺序,其他的为非必须安装包。

方法①:Mysql官网下载RPM包

å¨è¿éæå¥å¾çæè¿°

方法②:直接使用  wget 指令下载(网易地址)

wget https://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-community-common-8.0.20-1.el7.x86_64.rpm 
wget https://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-community-libs-8.0.20-1.el7.x86_64.rpm 
wget https://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-community-client-8.0.20-1.el7.x86_64.rpm 
wget https://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-community-server-8.0.20-1.el7.x86_64.rpm

2.检查是否安装过:

rpm -qa | grep -i mysql

3.卸载之前的安装:

rpm -e --nodeps 软件名 //强力删除,对相关依赖的文件也进行强力删除

 

4.安装RPM包:

 
rpm -ivh mysql-community-common-XXXXXX.rpm 
rpm -ivh mysql-community-libs-XXXXXX.rpm 
rpm -ivh mysql-community-client-XXXXXX.rpm 
rpm -ivh mysql-community-server-XXXXXX.rpm

报错:
警告:mysql-community-server-5.7.24-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature......
.  error: Failed dependencies:...... 

原因:这是由于yum安装了旧版本的GPG keys造成的

解决命令
sudo rpm -ivh --nodeps mysql-community-XXXXXX.rpm
或者 rpm -ivh mysql-xxxxxx.rpm --force --nodeps

提示:

--nodeps rpm在安装包时,不检查依赖关系,例如安装B,B依赖C导致无法安装,使用--nodeps就可以安装成功
 
--force 强制安装

 

5.安装完成之后查询版本:

mysqladmin --version

报错:

问题描述:mysqladmin: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory;启动时报错:

解决:尝试一些改软连接的方法都不好使,这里就不细说了,一下是我的解决方案,尝试有效;

在Linux中安装openssl10,进行OpenSSL升级(用yum升不上去,用rpm包简单有效),

具体操作:

1、下载rpm包

wget http://mirror.centos.org/centos/8/AppStream/x86_64/os/Packages/compat-openssl10-1.0.2o-3.el8.x86_64.rpm

2、安装rpm包

rpm -i compat-openssl10-1.0.2o-3.el8.x86_64.rpm

完美解决!

6.设置大小写不敏感:大小写不敏感:1;大小写敏感:0【默认】

#修改mysql配置文件
vi /etc/my.cnf
#增加如下配置选项
[mysqld]
lower_case_table_names=1

7.初始化mysql:

mysqld --initialize //创建数据文件目录和mysql系统数据库 产生随机root密码

8.启动mysql服务:

systemctl start mysqld

报错:

[root@localhost mysql8.0]# systemctl start mysqld

Job for mysqld.service failed because the control process exited with error code.

See "systemctl status mysqld.service" and "journalctl -xe" for details.

报错原因:启动失败,因为/var/lib/mysql目录权限不够

解决方法:授权:chown -R mysql:mysql /var/lib/mysql/

9.启动服务:

systemctl start mysqld 

10.查看mysql服务:

ps -ef | grep mysql

11.查看初始化随机生成的root密码:

[root@localhost mysql8.0]# cat /var/log/mysqld.log | grep password
2020-05-22T14:59:39.740017Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: won-V%kYc1al

12.安全设置【可忽略】 mysql_secure_installation

a)为root用户设置密码
b)删除匿名账号
c)取消root用户远程登录
d)删除test库和对test库的访问权限
e)刷新授权表使修改生效

[root@localhost mysql8.0]# mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:    //输入上面查到的临时密码  won-V%kYc1al
The existing password for the user account root has expired. Please set a new password.
New password:                    // 输入新密码 XXXXXXXX
Re-enter new password:           // 输入新密码 XXXXXXXX
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: y          //选择y
There are three levels of password validation policy:
LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0      //设置0
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : No    //是否需要修改root用户密码
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y            //继续使用提供的密码
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y     // 是否删除匿名用户
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : No    // 是否禁止root远程连接
... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y   // 是否删除测试数据库
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y    // 是否重新加载权限表
Success.

All done!

13.Mysql登录:

mysql -uroot -p   
密码上面修改的/临时密码

14.如何停止、重启和查看mysql服务:

systemctl stop mysqld //停止服务
systemctl restart mysqld //重启服务
systemctl status mysqld //查看服务

15.设置外网连接

如果"安全设置"忽略/没有修改临时密码,登录后要求重置密码,需要先执行:
alter user 'root'@'localhost' identified by 'root';  //修改密码
然后执行:
use mysql;    //指定数据库
update user set host = '%' where user = 'root';   //修改Host
flush privileges;    //刷新权限



注意:防火墙关闭或者放心Mysql数据库端口(默认3306),获得root 控制权限。在“#”下操作。

查看防火墙状态
systemctl status firewalld

查看端口状态 
firewall-cmd --zone=public --query-port=3306/tcp 

临时关闭防火墙命令。重启电脑后,防火墙自动起来。
systemctl stop firewalld

永久关闭防火墙命令。重启后,防火墙不会自动启动。
systemctl disable firewalld

打开防火墙命令。
systemctl enable firewalld

开放端口
firewall-cmd  --zone=public --add-port=3306/tcp --permanent

关闭端口 
firewall-cmd  --zone=public --remove-port=8090/tcp --permanent

使配置生效
firewall-cmd --reload

16.Mysql的相关安装目录文件:

 
/usr/bin        //相关命令
/etc/my.cnf     //mysql的启动配置文件
/var/lib/mysql  //数据库文件存放目录
/usr/share/mysql-8.0/ //配置文件目录
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值