首页 > 数据库 > MySQL > 正文

安装mysql数据库及问题解决办法

2024-07-24 12:31:57
字体:
来源:转载
供稿:网友
        安装mysql数据库及问题解决方法:

1、mysql官网下载安装包 
 
      [root@seiang software]# ll
 
      total 580020
 
      -rw-r--r--. 1 root root 593940480 Mar 25 18:57 mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar
 
2、解压
 
[root@seiang software]# tar xvf mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar
 
mysql-community-embedded-devel-5.7.21-1.el7.x86_64.rpm
 
mysql-community-minimal-debuginfo-5.7.21-1.el7.x86_64.rpm
 
mysql-community-common-5.7.21-1.el7.x86_64.rpm
  
3、全部安装,出现如下的报错
 
[root@seiang software]# rpm -ivh *.rpm
 
warning: mysql-community-client-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
 
4、如上的报错,由于centos 7默认是mariadb数据库,再去安装mysql之前要先下载mariadb
 
[root@seiang software]# rpm -qa | grep mariadb
 
mariadb-libs-5.5.41-2.el7_0.x86_64
 
由于存在依赖关系,强制卸载
 
[root@seiang software]# rpm -e --nodeps mariadb-libs-5.5.41-2.el7_0.x86_64
 
5、安装mysql-server,出现报错
 
[root@seiang software]# rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm
 
warning: mysql-community-server-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
 
6、根据提示,要先安装mysql-community-common和mysql-community-client包
 
[root@seiang software]# rpm -ivh mysql-community-common-5.7.21-1.el7.x86_64.rpm
 
 7、安装mysql-client包,出现如下的报错
 
[root@seiang software]# rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm
 
warning: mysql-community-client-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
 
error: Failed dependencies:
 
        mysql-community-libs(x86-64) >= 5.7.9 is needed by mysql-community-client-5.7.21-1.el7.x86_64
 
8、根据提示先安装 mysql-community-libs包
 
[root@seiang software]# rpm -ivh mysql-community-libs-5.7.21-1.el7.x86_64.rpm
 
9、再次尝试安装mysql-client
 
[root@seiang software]# rpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpm
 
warning: mysql-community-client-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
 
10、最后安装mysql-server
 
[root@seiang software]# rpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm
 
warning: mysql-community-server-5.7.21-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
 
Preparing...                          ################################# [100%]
 
Updating / installing...
 
   1:mysql-community-server-5.7.21-1.e################################# [100%]
 
11、查看mysql的服务
 
[root@seiang software]# systemctl status mysqld.service
 
mysqld.service - MySQL Server
 
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
 
   Active: inactive (dead)
 
     Docs: man:mysqld(8)
 
           http://dev.mysql.com/doc/refman/en/using-systemd.html
 
12、启动mysql服务
 
[root@seiang software]# systemctl start mysqld.service
 
[root@seiang software]#
 
[root@seiang software]# systemctl status mysqld.service
 
mysqld.service - MySQL Server
 
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
 
   Active: active (running) since Mon 2018-03-26 09:26:04 CST; 2s ago
 
 
13、mysql服务启动成功,首先使用临时的密码进行登录,查看临时密码
 
[root@seiang software]#  grep "password" /var/log/mysqld.log
 
2018-03-25T11:18:09.770923Z 1 [Note] A temporary password is generated for root@localhost: &)2KIh?M3hr7
  
 
2018-03-26T01:25:57.938742Z 1 [Note] A temporary password is generated for root@localhost: v,esvf2?oj?T

(编辑:武林网)

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表