美文网首页
centos7安装mysql

centos7安装mysql

作者: 技术永无止境 | 来源:发表于2019-06-09 23:46 被阅读0次

    1.下载mysql安装文件:

    #mysql5.6下载地址,centos7下载redhat7版本:
    https://dev.mysql.com/downloads/mysql/5.6.html#downloads
    

    2.卸载已有mysql

    #查看是否存在mysql
    rpm -qa | grep -i mysql
    #如果存在使用以下指令卸载。
    rpm -e --nodeps ...
    #删除服务
    systemctl list-unit-files --type=service | grep -i mysql
    #如果查找到mysql服务,使用下面的命令进行删除
    chkconfig --del mysql
    #删除mysql分散的文件夹
    [root@zzm-yun-pc ~]#whereis mysql
    mysql: /usr/lib64/mysql
    rm -rf /usr/lib64/mysql
    

    2.上传文件到/usr/local/share/mysql中

    #执行指令
    tar -xvf MySQL-5.6.44-1.el7.x86_64.rpm-bundle.tar 
    #解压得到
    MySQL-5.6.44-1.el7.x86_64.rpm-bundle.tar
    MySQL-client-5.6.44-1.el7.x86_64.rpm
    MySQL-devel-5.6.44-1.el7.x86_64.rpm
    MySQL-embedded-5.6.44-1.el7.x86_64.rpm
    MySQL-server-5.6.44-1.el7.x86_64.rpm
    MySQL-shared-5.6.44-1.el7.x86_64.rpm
    MySQL-shared-compat-5.6.44-1.el7.x86_64.rpm
    MySQL-test-5.6.44-1.el7.x86_64.rpm
    

    3.安装mysql

    #执行指令
    rpm  -ivh MySQL-server-5.6.44-1.el7.x86_64.rpm
    #提示错误
    error: Failed dependencies:
            libaio.so.1()(64bit) is needed by MySQL-server-5.6.44-1.el7.x86_64
    #先安装libaio
    yum install libaio
    #再安装mysql报错
    error: Failed dependencies:
            perl(Data::Dumper) is needed by MySQL-server-5.6.44-1.el7.x86_64
    #执行如下指令
    yum install perl
    yum -y install autoconf
    #再执行
     rpm -ivh MySQL-server-5.6.44-1.el7.x86_64.rpm 
    #报错
    warning: MySQL-server-5.6.44-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    Preparing...                          ################################# [100%]
            file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.44-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.60-1.el7_5.x86_64
    #卸载mariadb
    rpm -qa | grep -i mariadb
    rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
    rpm -e --nodeps mariadb-5.5.60-1.el7_5.x86_64
    #安装
    rpm  -ivh MySQL-server-5.6.44-1.el7.x86_64.rpm
    rpm -ivh MySQL-client-5.6.44-1.el7.x86_64.rpm 
    rpm -ivh MySQL-devel-5.6.44-1.el7.x86_64.rpm
    #查看mysql是否安装成功
    rpm -qa|grep -i mysql
    [root@zzm-yun-pc ~]# rpm -qa|grep -i mysql
    MySQL-server-5.6.44-1.el7.x86_64
    MySQL-devel-5.6.44-1.el7.x86_64
    MySQL-client-5.6.44-1.el7.x86_64
    #验证mysql是否安装成功
    mysqladmin --version
    #启动mysql
    service start mysql
    #修改mysql初始密码
    vi /root/.mysql_secret
    mysql -u root -p
    SET PASSWORD = PASSWORD('mysql2017ylz');
     use mysql;  
    #查看是否开启远程root登录数据库
    select host,user from user;
    #如果没有开启执行下列语句
    update user set host = '%' where user = 'root';
    #创建用户
     create user mysql identified by 'mysql'
    #授权
    grant all privileges on *.* to mysql@'%' identified by 'mysql';
    flush privileges;
    #接下来就可以用新建的用户登录了
    

    相关文章

      网友评论

          本文标题:centos7安装mysql

          本文链接:https://www.haomeiwen.com/subject/kxcuxctx.html