精华内容
下载资源
问答
  • centos7离线安装mysql5.7

    2020-07-16 17:50:18
    centos7离线安装mysql5.7 参考文章:https://www.cnblogs.com/yy3b2007com/p/10497787.html 1、去官网下载安装包 官网下载地址:https://dev.mysql.com/downloads/mysql/5.7.html#downloads 版本:mysql-5.7.20-...

    centos7离线安装mysql5.7

    参考文章:https://www.cnblogs.com/yy3b2007com/p/10497787.html

    1、去官网下载安装包

    官网下载地址:https://dev.mysql.com/downloads/mysql/5.7.html#downloads
    版本:mysql-5.7.20-linux-glibc2.12-x86_64.tar
    在这里插入图片描述

    2、卸载CentOS7系统自带mariadb

    # 查看系统自带的Mariadb
    rpm -qa|grep mariadb
    
    # 卸载系统自带的Mariadb
    rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64
    # 删除etc目录下的my.cnf
     rm /etc/my.cnf
    
    

    3、检查mysql在不在

    rpm -qa | grep mysql

    4、检查mysql组和用户是否存在,如无则创建(不知道这一步有什么用)

    cat /etc/group | grep mysql
    cat /etc/passwd | grep mysql 

    若不存在,则创建mysql组和用户

    创建mysql用户组

     groupadd mysql

    #创建一个用户名为mysql的用户,并加入mysql用户组

    useradd -g mysql mysql

    制定password 为111111

     passwd mysql

    然后就要输密码:
    Changing password for user mysql.
    New password:
    BAD PASSWORD: The password is a palindrome
    Retype new password:
    passwd: all authentication tokens updated successfully.

    5、用ftp工具上传下载的tar包

    把解压好的tar包放到/usr/local/文件夹在这里插入图片描述
    进入/usr/local下,修改为mysql

    [root@localhost local]# mv mysql-5.7.20-linux-glibc2.12-x86_64 mysql

    6、更改所属的组和用户

    [root@localhost local]# chown -R mysql mysql/
    [root@localhost local]# chgrp -R mysql mysql/
    [root@localhost local]# cd mysql/
    [root@localhost mysql]# mkdir data
    [root@localhost mysql]# chown -R mysql:mysql data

    7、在/etc下创建my.cnf文件

    [root@localhost mysql]# touch my.cnf
    [root@localhost mysql]# vi my.conf

    my.conf里面放这些

    [mysql]
    socket=/var/lib/mysql/mysql.sock
    # set mysql client default chararter
    default-character-set=utf8
    
    [mysqld]
    socket=/var/lib/mysql/mysql.sock
    # set mysql server port  
    port = 3323 #默认是3306,这里发现3306已经被占用,因此防止这种情况发生,可以避免使用3306mysql默认端口
    # set mysql install base dir
    basedir=/usr/local/mysql
    # set the data store dir
    datadir=/usr/local/mysql/data
    # set the number of allow max connnection
    max_connections=200
    # set server charactre default encoding
    character-set-server=utf8
    # the storage engine
    default-storage-engine=INNODB
    lower_case_table_names=1
    max_allowed_packet=16M
    explicit_defaults_for_timestamp=true
    
    [mysql.server]
    user=mysql
    basedir=/usr/local/mysql
    然后保存,退出。
    
    
    
    
    ###

    8、进入mysql文件夹,并安装mysql

      [root@localhost mysql]# bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

    设置文件及目录权限:

    [root@localhost mysql]# cp ./support-files/mysql.server /etc/init.d/mysqld
    [root@localhost mysql]# chown 777 my.cnf
    [root@localhost mysql]# ls
    [root@localhost mysql]# chmod +x /etc/init.d/mysqld
    [root@localhost mysql]# mkdir data
    [root@localhost mysql]# chown -R mysql:mysql data
    

    9、启动mysql

    [root@localhost mysql]# /etc/init.d/mysqld restart
    设置开机启动
    [root@localhost mysql]# chkconfig --level 35 mysqld on
    [root@localhost mysql]# chkconfig --list mysqld
    [root@localhost mysql]# chmod +x /etc/rc.d/init.d/mysqld
    [root@localhost mysql]# chkconfig --add mysqld
    [root@localhost mysql]# chkconfig --list mysqld
    [root@localhost mysql]# service mysqld status

    10、修改配置文件

    # 进入/etc/profile文件夹
    [root@localhost mysql]#vim /etc/profile
    修改/etc/profile,在最后添加如下内容:
    #set mysql environment
    export PATH=$PATH:/usr/local/mysql/bin
    然后保存
    # 使文件生效
    [root@localhost mysql]#  source /etc/profile
    

    11、获得mysql初始密码

    [root@localhost mysql]# cat /root/.mysql_secret

    # Password set for user 'root@localhost' at 2020-07-16 15:04:58 
    rWaheugBDI*7
    [root@localhost mysql]# mysql -uroot -p
    Enter password: 
    mysql> set PASSWORD = PASSWORD('123456');
    mysql> flush privileges;
    mysql> exit

    12、添加远程权限

    mysql> use mysql
    mysql> update user set host='%' where user='root';
    mysql> select host,user from user;

    13、重启mysql生效

     /etc/init.d/mysqld restart
    展开全文
  • CentOS7 离线安装 Mysql5.7 资源下载 1,前往Mysql官网选择对应版本进行下载。 2,官网下载比较慢,可以使用CSDN下载。 卸载mariadb # rpm -qa | grep mariadb mariadb-libs-5.5.60-1.el7_5.x86_64 # rpm -e mariadb...

    CentOS7 离线安装 Mysql5.7

    资源下载

    1,前往Mysql官网选择对应版本进行下载。
    2,官网下载比较慢,可以使用CSDN下载

    卸载mariadb

    # rpm -qa | grep mariadb
    mariadb-libs-5.5.60-1.el7_5.x86_64
    # rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64
    错误:依赖检测失败:
            libmysqlclient.so.18()(64bit) 被 (已安裝) net-snmp-1:5.7.2-37.el7.x86_64 需要
            libmysqlclient.so.18()(64bit) 被 (已安裝) postfix-2:2.10.1-7.el7.x86_64 需要
            libmysqlclient.so.18()(64bit) 被 (已安裝) libmapi-7.1.14-3.el7.x86_64 需要
            libmysqlclient.so.18(libmysqlclient_18)(64bit) 被 (已安裝) postfix-2:2.10.1-7.el7.x86_64 需要
            libmysqlclient.so.18(libmysqlclient_18)(64bit) 被 (已安裝) libmapi-7.1.14-3.el7.x86_64 需要
            mysql-libs 被 (已安裝) net-snmp-1:5.7.2-37.el7.x86_64 需要
    

    遇到报错,进行强制卸载。

    # rpm --nodeps -e mariadb-libs-5.5.60-1.el7_5.x86_64
    

    安装Mysql

    # tar -xvf mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar
    
    # rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm
    # rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm
    # rpm -ivh mysql-community-devel-5.7.28-1.el7.x86_64.rpm
    # rpm -ivh mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm
    # rpm -ivh mysql-community-client-5.7.28-1.el7.x86_64.rpm
    # rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm
    

    启动Mysql服务

    # systemctl restart mysqld
    # systemctl enable mysqld
    

    开启防火墙

    # firewall-cmd --add-port=3306/tcp --permanent
    # firewall-cmd --reload
    # firewall-cmd --list-all
    
    展开全文
  • 目的:Centos7 离线安装mysql 5.7 环境: 系统:Centos 7.5 环境:x64 问题分析: Centos7 移除了mysql默认安装,改换为mariadb。mysql需要手动安装 解决方案: 先移除mariadb的lib,避免mysql安装时出错...

    目的:Centos7 离线安装mysql 5.7

    环境:

    系统:Centos 7.5
    环境:x64
    

    问题分析:

    Centos7 移除了mysql默认安装,改换为mariadb。mysql需要手动安装

    解决方案:

    先移除mariadb的lib,避免mysql安装时出错。同时下载mysql rpm离线包,进行安装及权限设置。

    方法步骤:

    1. 卸载Centos7默认的mariadb

    执行命令 rpm -qa | grep mariadb            //查找mariadb安装情况
    执行命令 rpm -e --nodeps mariadb-libs      //卸载mariadb
    

    2. 官网https://dev.mysql.com/downloads/mysql/下载mysql。以5.7.24版本为例,下载完整离线包https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.24-1.el7.x86_64.rpm-bundle.tar
    进入官网
    选择对应版本
    选择对应版本并下载
    解压下载包
    解压后的文件夹
    3. 安装mysql

    1. 解压后的rpm文件拷贝到Centos7 环境下。
     
    2. 执行安装命令
      rpm -ivh mysql-community-common-5.7.24-1.el7.x86_64.rpm
      rpm -ivh mysql-community-libs-5.7.24-1.el7.x86_64.rpm
      rpm -ivh mysql-community-devel-5.7.24-1.el7.x86_64.rpm
      rpm -ivh mysql-community-libs-compat-5.7.24-1.el7.x86_64.rpm
      rpm -ivh mysql-community-client-5.7.24-1.el7.x86_64.rpm
      rpm -ivh mysql-community-server-5.7.24-1.el7.x86_64.rpm
    	
    3. 安装命令全部执行成功以后mysql安装完成。
    

    4. 配置mysql

    1. 打开配置文件 
      vim /etc/my.cnf
    
    2. 在最后添加一行
      skip-grant-tables     #屏蔽mysql登陆密码,并且可以操作mysql的user表
    
    3. 重启mysql服务
      systemctl restart mysqld   
    
    4. mysql命令登陆
      mysql -u root -p
      回车进入mysql>
    
    5. 修改用户密码及网络访问(解决MySQL Access denied for user)
      mysql> use mysql;
      mysql> update mysql.user set authentication_string=password('新密码') where user='root'  ;//设置密码
      mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option; //开启网络访问
      mysql> flush privileges;  //刷新权限
      mysql> exit;
    
    6. 还原配置
      vim /etc/my.cnf 
      注释配置文件添加的最后一行
      #skip-grant-tables  
    
    7.重启
      systemctl restart mysqld    //重启mysql
    
    

    5. 开始使用mysql.

    ps:
    如启动mysql出错,提示如 Job for mysqld.service failed because the control process exited with error code.
    可以通过查看mysql启动log来查看原因,log位置在/var/log/mysqld.log.

    1. 若错误原因是: The innodb_system data file ‘ibddata1’ must be writable.
      解决方法: 找到ibddata1文件位置(本例位置在/usr/local/mysql/data),赋予写权限。执行 chmod -R 777 /usr/local/mysql/data , 然后systemctl restart mysqld
    展开全文
  • centos7下使用mysql离线安装包安装mysql5.7 尊重原创:https://www.cnblogs.com/yy3b2007com/p/10497787.html 在自己博客中记录安装成功。。。 服务器环境: centos7 x64 需要安装mysql5.7+ 一、卸载CentOS7...

    centos7下使用mysql离线安装包安装mysql5.7

    尊重原创:https://www.cnblogs.com/yy3b2007com/p/10497787.html 
    在自己博客中记录安装成功。。。

    服务器环境:

    centos7 x64

    需要安装mysql5.7+

    一、卸载CentOS7系统自带mariadb

     

    # 查看系统自带的Mariadb
    [root@CDH-141 ~]# rpm -qa|grep mariadb
    mariadb-libs-5.5.44-2.el7.centos.x86_64
    # 卸载系统自带的Mariadb
    [root@CDH-141 ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64
    # 删除etc目录下的my.cnf
    [root@CDH-141 ~]# rm /etc/my.cnf

     

    二、检查mysql是否存在

    # 检查mysql是否存在
    [root@CDH-141 ~]# rpm -qa | grep mysql
    [root@CDH-141 ~]# 

    三、查看用户和组是否存在

    1)检查mysql组合用户是否存在

    # 检查mysql组和用户是否存在,如无则创建
    [root@CDH-141 ~]# cat /etc/group | grep mysql
    [root@CDH-141 ~]# cat /etc/passwd | grep mysql 

    # 查询全部用户(只是做记录,没必要执行)

     

    [root@CDH-141 ~]# cat /etc/passwd|grep -v nologin|grep -v halt|grep -v shutdown|awk -F ":" '{print $1 "|" $3 "1" $4}' | more
    root|010
    sync|510
    flume|9921989
    hdfs|9911988
    zookeeper|9891986
    llama|9881985
    httpfs|9871984
    mapred|9861983
    sqoop|9851982
    yarn|9841981
    kms|9831980
    hive|9821979
    oozie|9801977
    hbase|9781975
    impala|9761973
    hue|9741971
    wlaqzc2018|100111001
    [root@CDH-141 mysql]# 

     

    2)若不存在,则创建mysql组和用户

     

    # 创建mysql用户组
    [root@CDH-141 ~]# groupadd mysql
    # 创建一个用户名为mysql的用户,并加入mysql用户组
    [root@CDH-141 ~]# useradd -g mysql mysql
    # 制定password 为111111
    [root@CDH-141 ~]# passwd mysql
    Changing password for user mysql.
    New password:
    BAD PASSWORD: The password is a palindrome
    Retype new password:
    passwd: all authentication tokens updated successfully.

     

    四、下载mysql离线安装包tar文件

    官网下载地址:https://dev.mysql.com/downloads/mysql/5.7.html#downloads

    版本选择,可以选择一下两种方式:

    1)使用Red Hat Enterprise Linux
    Select Version:5.7.25
    Select Operating System:Red Hat Enterprise Linux / Oracle Linux
    Select OS Version:Red Hat Enterprise Linux 7 / Oracle Linux 7 (x86, 64-bit)
    列表中下载:
    Compressed TAR Archive:(mysql-5.7.25-el7-x86_64.tar.gz)
    2)使用Linux - Generic
    Select Version:5.7.25
    Select Operating System:Linux - Generic
    Select OS Version:Linux - Generic (glibc 2.12) (x86, 64-bit)
    列表中下载:
    Compressed TAR Archive:(mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz)【本文中使用的是这个版本】
    注意:上边两种方式找mysql离线安装包的方式都可以。

    五、上传第四步下载的mysql TAR包

     

    # 进入/usr/local/文件夹
    [root@CDH-141 ~]# cd /usr/local/
    # 上传mysql TAR包
    [root@CDH-141 local]# rz
    # 解压mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
    [root@CDH-141 local]# ls
    bin  full-path-to-mysql-VERSION-OS  include  lib64    mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz  share
    etc  games                          lib      libexec  sbin                                 src
    [root@CDH-141 local]# tar -zxvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
    mysql-5.7.25-lin
    ...
    mysql-5.7.25-linux-glibc2.12-x86_64/share/install_rewriter.sql
    mysql-5.7.25-linux-glibc2.12-x86_64/share/uninstall_rewriter.sql
    mysql-5.7.25-linux-glibc2.12-x86_64/support-files/magic
    mysql-5.7.25-linux-glibc2.12-x86_64/support-files/mysql.server
    mysql-5.7.25-linux-glibc2.12-x86_64/docs/INFO_BIN
    mysql-5.7.25-linux-glibc2.12-x86_64/docs/INFO_SRC
    [root@CDH-141 local]# ls
    bin  full-path-to-mysql-VERSION-OS  include  lib64    mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz  share
    etc  games                          lib      libexec  mysql-5.7.25-linux-glibc2.12-x86_64  sbin                                        src
    # 进入/usr/local下,修改为mysql
    [root@CDH-141 local]# mv mysql-5.7.25-linux-glibc2.12-x86_64 mysql
    [root@CDH-141 local]# ls
    bin  etc  full-path-to-mysql-VERSION-OS  games  include  lib  lib64  libexec  mysql  mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz  sbin  share  src

     

    六、更改所属的组和用户

     

    # 更改所属的组和用户
    [root@CDH-141 ~]# cd /usr/local/
    [root@CDH-141 local]# chown -R mysql mysql/
    [root@CDH-141 local]# chgrp -R mysql mysql/
    [root@CDH-141 local]# cd mysql/
    [root@CDH-141 mysql]# mkdir data
    [root@CDH-141 mysql]# chown -R mysql:mysql data

     

    七、在/etc下创建my.cnf文件

     

    # 进入/usr/local/mysql文件夹下
    [root@CDH-141 ~]# cd /usr/local/mysql
    # 创建my.cnf文件
    [root@CDH-141 mysql]# touch my.cnf #或者cd ''>my.conf
    # 编辑my.cnf
    [root@CDH-141 mysql]# vi my.conf
    [mysql]
    socket=/var/lib/mysql/mysql.sock
    # set mysql client default chararter
    default-character-set=utf8
    
    [mysqld]
    socket=/var/lib/mysql/mysql.sock
    # set mysql server port  
    port = 3323 #默认是3306,这里发现3306已经被占用,因此防止这种情况发生,可以避免使用3306mysql默认端口
    # set mysql install base dir
    basedir=/usr/local/mysql
    # set the data store dir
    datadir=/usr/local/mysql/data
    # set the number of allow max connnection
    max_connections=200
    # set server charactre default encoding
    character-set-server=utf8
    # the storage engine
    default-storage-engine=INNODB
    lower_case_table_names=1
    max_allowed_packet=16M
    explicit_defaults_for_timestamp=true
    
    [mysql.server]
    user=mysql
    basedir=/usr/local/mysql
    [root@CDH-141 mysql]# 

    copycode.gifuploading.4e448015.gif转存失败重新上传取消复制代码

    八、进入mysql文件夹,并安装mysql

     

    # 进入mysql
    [root@CDH-141 local]# cd /usr/local/mysql
    # 安装mysql
    [root@CDH-141 mysql]# bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
    2019-03-08 18:11:07 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
    2019-03-08 18:11:24 [WARNING] The bootstrap log isn't empty:
    2019-03-08 18:11:24 [WARNING] 2019-03-08T10:11:07.208602Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead

     

    设置文件及目录权限:

     

    [root@CDH-141 mysql]# cp ./support-files/mysql.server /etc/init.d/mysqld
    [root@CDH-141 mysql]# chown 777 my.cnf
    [root@CDH-141 mysql]# ls
    bin  COPYING  data  docs  include  lib  man  my.cnf  README  share  support-files
    [root@CDH-141 mysql]# ls -l
    total 60
    drwxr-xr-x  2 root  root   4096 Mar  8 15:56 bin
    -rw-r--r--  1  7161 31415 17987 Dec 21 18:39 COPYING
    drwxr-x---  5 mysql mysql  4096 Mar  8 16:21 data
    drwxr-xr-x  2 root  root   4096 Mar  8 15:56 docs
    drwxr-xr-x  3 root  root   4096 Mar  8 15:56 include
    drwxr-xr-x  5 root  root   4096 Mar  8 15:56 lib
    drwxr-xr-x  4 root  root   4096 Mar  8 15:56 man
    -rw-r--r--  1   777 root    516 Mar  8 16:19 my.cnf
    -rw-r--r--  1  7161 31415  2478 Dec 21 18:39 README
    drwxr-xr-x 28 root  root   4096 Mar  8 15:56 share
    drwxr-xr-x  2 root  root   4096 Mar  8 15:56 support-files
    [root@CDH-141 mysql]# chmod +x /etc/init.d/mysqld
    [root@CDH-141 mysql]#
    [root@CDH-141 mysql]# mkdir data
    [root@CDH-141 mysql]#
    [root@CDH-141 mysql]# chown -R mysql:mysql data
    [root@CDH-141 mysql]# 

     

    九、启动mysql

     

    # 启动mysql
    [root@CDH-141 mysql]# /etc/init.d/mysqld restart
    MySQL server PID file could not be found![FAILED]
    Starting MySQL.Logging to '/usr/local/mysql/data/CDH-141.err'.
    ..The server quit without updating PID file (/usr/local/mysql/data/CDH-141.pid).[FAILED]
    [root@CDH-141 mysql]# 

     

    出现错误,解决方案如下:

     

    #找到是否已经有进程占用
    [root@CDH-141 mysql]# ps aux|grep mysql
    root     32483  0.0  0.0 113252  1620 pts/0    S    18:04   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/CDH-141.pid
    mysql    32684  0.1  0.1 1119892 178224 pts/0  Sl   18:04   0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=CDH-141.err --pid-file=/usr/local/mysql/data/CDH-141.pid --port=3323
    root     35137  0.0  0.0 112648   944 pts/0    S+   18:12   0:00 grep --color=auto mysql
    
    #关闭进程
    [root@CDH-141 mysql]# kill -9 32684
    [root@CDH-141 mysql]# /usr/local/mysql/bin/mysqld_safe: line 198: 32684 Killed                  nohup /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=CDH-141.err --pid-file=/usr/local/mysql/data/CDH-141.pid --port=3323 < /dev/null > /dev/null 2>&1
    #确认是否还占用
    [root@CDH-141 mysql]#  ps aux|grep mysql
    root     35501  0.0  0.0 112644   948 pts/0    S+   18:13   0:00 grep --color=auto mysql
    [root@CDH-141 mysql]# /etc/init.d/mysqld restart
    MySQL server PID file could not be found![FAILED]
    Starting MySQL..[  OK  ]
    [root@CDH-141 mysql]#
    
    # 重启mysql
    [root@CDH-141 mysql]# /etc/init.d/mysqld restart
    Shutting down MySQL..[  OK  ]
    Starting MySQL..[  OK  ]
    [root@CDH-141 mysql]# 

     

    十、设置开机启动

     

    #设置开机启动
    [root@CDH-141 mysql]# chkconfig --level 35 mysqld on
    [root@CDH-141 mysql]# chkconfig --list mysqld
    
    Note: This output shows SysV services only and does not include native
          systemd services. SysV configuration data might be overridden by native
          systemd configuration.
    
          If you want to list systemd services use 'systemctl list-unit-files'.
          To see services enabled on particular target use
          'systemctl list-dependencies [target]'.
    
    mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
    [root@CDH-141 mysql]# chmod +x /etc/rc.d/init.d/mysqld
    [root@CDH-141 mysql]# chkconfig --add mysqld
    [root@CDH-141 mysql]# chkconfig --list mysqld
    
    Note: This output shows SysV services only and does not include native
          systemd services. SysV configuration data might be overridden by native
          systemd configuration.
    
          If you want to list systemd services use 'systemctl list-unit-files'.
          To see services enabled on particular target use
          'systemctl list-dependencies [target]'.
    
    mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
    [root@CDH-141 mysql]# service mysqld status
    MySQL running (26122)[  OK  ]
    [root@CDH-141 mysql]# 

     

    十一、修改配置文件

     

    # 进入/etc/profile文件夹
    [root@CDH-141 mysql]# vim /etc/profile
    修改/etc/profile,在最后添加如下内容
    # 修改/etc/profile文件
    #set mysql environment
    export PATH=$PATH:/usr/local/mysql/bin
    # 使文件生效
    [root@CDH-141 mysql]# source /etc/profile

     

    十二、获得mysql初始密码

     1)获得mysql初始密码

    [root@CDH-141 mysql]#  cat /root/.mysql_secret  
    # Password set for user 'root@localhost' at 2019-03-08 17:40:42
    poc3u0mO_luv
    [root@CDH-141 mysql]# 

    2)修改密码

     

    [root@CDH-141 mysql]# mysql -uroot -p
    Enter password: #此处填写上边获取到的初始密码‘poc3u0mO_luv’
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 2
    Server version: 5.7.25
    
    Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
    Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql>  set PASSWORD = PASSWORD('123456');
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> exit
    Bye

     

    3)验证新密码是否登录成功:

     

    [root@CDH-141 mysql]# mysql -uroot -p
    Enter password: #此处输入新密码‘123456’
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 4
    Server version: 5.7.25 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
    Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> show tables;
    ERROR 1046 (3D000): No database selected
    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    4 rows in set (0.00 sec)
    
    mysql> 

     

    十三、添加远程访问权限

     

    # 添加远程访问权限
    mysql> use mysql
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed
    mysql> update user set host='%' where user='root';
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    mysql> select host,user from user;
    +-----------+---------------+
    | host      | user          |
    +-----------+---------------+
    | %         | root          |
    | localhost | mysql.session |
    | localhost | mysql.sys     |
    +-----------+---------------+
    3 rows in set (0.00 sec)
    
    mysql> 

     

    十四、重启mysql生效

    # 重启mysql
    [root@CDH-141 mysql]# /etc/init.d/mysqld restart
    Shutting down MySQL..[  OK  ]
    Starting MySQL..[  OK  ]
    [root@CDH-141 mysql]# 
    展开全文
  • Centos7离线安装mysql5.7

    千次阅读 2020-02-29 23:30:27
    1、mysql官网下载离线安装包mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar 2、将mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar安装包上传到centos服务器/data/soft目录下,并解压 tar -xvf mysql-5.7.29-1.el7.x86_64.rpm-...
  • CentOS7 离线安装mysql5.7

    2021-02-26 16:01:57
    准备条件 mysql5.7安装包官网下载 上传到系统指定位置备用 一般放于/usr/local目录下 添加mysql用户组和用户groupadd mysql useradd -r -g mysql -s /bin/false mysql
  • Centos7 离线安装mysql5.7

    千次阅读 2019-06-19 16:05:49
    目录 1.安装包下载 2.解压安装包并安装 3.配置数据库 3.1首先找到my.cnf文件进行编辑 3.2启动mysql 服务 ...mysql5.7 版本下载:https://dev.mysql.com/downloads/mysql/5.7.html#downloads 安装新版mysql前...
  • Centos7离线安装MySQL5.7

    2019-06-24 22:42:45
    1、centos7安装MySQL的方法很多,本次使用.tar.gz完成MySQL5.7的安装; 2、配置MySQL使之正常访问。 过程: 1、删除centos7自带的Mariadb数据库 #查看centos默认的数据库,如果有则删除默认数据库 rpm -qa|grep...
  • 网上已经有那么多的关于CentOS 7如何安装MySQL的文章了, 那为什么我还要写这没一篇关于CentOS 7安装MySQL的文章呢?主要有以下几个原因: 网上很多都是在线安装;由于很多时候,在生产环境进行部署时,生产机器...
  • centos7 离线安装 mysql5.7(记一次踩坑经过)
  • CentOS7离线安装mysql5.7

    2019-01-28 16:45:00
    下载mysql5.7,系统选择redhat,版本选择RHEL7,下载RPM Bundle后得到一个tar文件。这里得到文件mysql-5.7.25-1.el7.x86_64.rpm-bundle.tar,接下来解出文件。 tar -xf mysql-5.7.25-1.el7.x86_64.rpm-bundle.tar ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 493
精华内容 197
关键字:

centos7离线安装mysql5.7

mysql 订阅