Linux下的 Mysql 8.0 yum 安装 并修改密码

1.MySQL版本:

mysql> select @@version;
+-----------+
| @@version |
+-----------+
| 8.0.18 |
+-----------+
1 row in set (0.00 sec)

2.Centos操作系统版本

[[email protected] /]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)    

二、Mysql现在以及解压

1. 地址:https://downloads.mysql.com/archives/community/

2.linux中下载

1.在命令中输入这个语句,获取 mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar:

wget https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar

2.解压:

tar -xvf mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar

-rw-r--r-- 1 root root 684851200 9月 23 15:36 mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar
-rw-r--r-- 1 7155 31415 40104640 9月 23 15:19 mysql-community-client-8.0.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 611436 9月 23 15:20 mysql-community-common-8.0.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 6915400 9月 23 15:20 mysql-community-devel-8.0.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 23683600 9月 23 15:20 mysql-community-embedded-compat-8.0.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 3877664 9月 23 15:20 mysql-community-libs-8.0.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 1363968 9月 23 15:20 mysql-community-libs-compat-8.0.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 450282440 9月 23 15:21 mysql-community-server-8.0.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 158001648 9月 23 15:22 mysql-community-test-8.0.18-1.el7.x86_64.rpm

三、安装

1. 卸载系统自带的mariadb-lib

查看mariadb版本
rpm -qa|grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64

卸载mariadb
rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps

2.安装依赖环境

yum install -y openssl-devel.x86_64 openssl.x86_64
yum install -y libaio.x86_64 libaio-devel.x86_64
yum install -y perl.x86_64 perl-devel.x86_64
yum install -y perl-JSON.noarch
yum install -y autoconf
yum install -y wget
yum install -y net-tools

3.关闭防火墙

systemctl stop firewalld.service
systemctl disable firewalld.service

4.禁用selinux

vi /etc/selinux/config
SELINUX=enforcing改为SELINUX=disabled
reboot 重启机器

5.安装

/**

必须按顺序装,防止出现未知的问题

*/

rpm -ivh mysql-community-common-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm

--------------------------------------------------------------------------------

rpm -ivh mysql-community-libs-compat-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-embedded-compat-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-test-8.0.18-1.el7.x86_64.rpm

--初始化数据库
mysqld --initialize --console
--目录授权,否则启动失败
chown -R mysql:mysql /var/lib/mysql/
--启动服务
systemctl start mysqld

6.登陆密码设置

//报错
ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘localhost‘ (111)  ‘1)更改配置,此处可以跳过密码设置
vi /etc/my.cnf
#在mysqld模块下添加
skip-grant-tables// password 函数在MySQL8中位置,以下步骤未实现
2)重启服务:
systemctl restart mysqld
3) 按照传统改密码方式发现没有 password这个字段。
mysql> update user set password=password(‘123‘) where user=‘root‘;
ERROR 1054 (42S22): Unknown column ‘password‘ in ‘field list‘

网上查了一下据说5.7 版本password 字段改成authentication_string  password函数未知

mysql> update user set authentication_string=password(‘123‘) where user=‘root‘;
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

user 表的管理字段

+--------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Field                    | Type                              | Null | Key | Default               | Extra |
+--------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Host                     | char(255)                         | NO   | PRI |                       |       |
| User                     | char(32)                          | NO   | PRI |                       |       |
| Select_priv              | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Insert_priv              | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Update_priv              | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Delete_priv              | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Create_priv              | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Drop_priv                | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Reload_priv              | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Shutdown_priv            | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Process_priv             | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| File_priv                | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Grant_priv               | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| References_priv          | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Index_priv               | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Alter_priv               | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Show_db_priv             | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Super_priv               | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Create_tmp_table_priv    | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Lock_tables_priv         | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Execute_priv             | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Repl_slave_priv          | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Repl_client_priv         | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Create_view_priv         | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Show_view_priv           | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Create_routine_priv      | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Alter_routine_priv       | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Create_user_priv         | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Event_priv               | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Trigger_priv             | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Create_tablespace_priv   | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| ssl_type                 | enum(‘‘,‘ANY‘,‘X509‘,‘SPECIFIED‘) | NO   |     |                       |       |
| ssl_cipher               | blob                              | NO   |     | NULL                  |       |
| x509_issuer              | blob                              | NO   |     | NULL                  |       |
| x509_subject             | blob                              | NO   |     | NULL                  |       |
| max_questions            | int(11) unsigned                  | NO   |     | 0                     |       |
| max_updates              | int(11) unsigned                  | NO   |     | 0                     |       |
| max_connections          | int(11) unsigned                  | NO   |     | 0                     |       |
| max_user_connections     | int(11) unsigned                  | NO   |     | 0                     |       |
| plugin                   | char(64)                          | NO   |     | caching_sha2_password |       |
| authentication_string    | text                              | YES  |     | NULL                  |       |
| password_expired         | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| password_last_changed    | timestamp                         | YES  |     | NULL                  |       |
| password_lifetime        | smallint(5) unsigned              | YES  |     | NULL                  |       |
| account_locked           | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Create_role_priv         | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Drop_role_priv           | enum(‘N‘,‘Y‘)                     | NO   |     | N                     |       |
| Password_reuse_history   | smallint(5) unsigned              | YES  |     | NULL                  |       |
| Password_reuse_time      | smallint(5) unsigned              | YES  |     | NULL                  |       |
| Password_require_current | enum(‘N‘,‘Y‘)                     | YES  |     | NULL                  |       |
| User_attributes          | json                              | YES  |     | NULL                  |       |
+--------------------------+-----------------------------------+------+-----+-----------------------+-------+
51 rows in set (0.01 sec)

4.更改配置重启

[[email protected] ~]# vi /etc/my.cnf注释 # skip-grant-tables
[[email protected] ~]# systemctl restart mysqld
[[email protected] ~]# mysql -uroot -p123
5.成功:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.18 MySQL Community Server - GPL

Copyright (c) 2000, 2019, 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>

 

7.其他

[[email protected]00 log]# service mysqld start
Redirecting to /bin/systemctl start  mysqld.service
[[email protected]-00 log]# service mysqld status
Redirecting to /bin/systemctl status  mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 二 2020-02-25 19:09:37 CST; 2s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 3282 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 3306 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─3306 /usr/sbin/mysqld

2月 25 19:09:35 Hadoop-00 systemd[1]: Starting MySQL Server...
2月 25 19:09:37 Hadoop-00 systemd[1]: Started MySQL Server.

2. 如果安装过程出现操作失误问题,卸载MySQL重新开始

yum remove  mysql-community-client.x86_64
yum remove  mysql-community-common.x86_64
yum remove  mysql-community-devel.x86_64
yum remove  mysql-community-embedded-compat.x86_64
yum remove  mysql-community-libs.x86_64
yum remove  mysql-community-libs-compat.x86_64
yum remove  mysql-community-server.x86_64
yum remove  mysql-community-test.x86_64
yum remove  mysql57-community-release.noarch
------------------------------------------------------------------------
rm -rf /etc/rc.d/init.d/mysql
rm -rf /etc/selinux/targeted/active/modules/100/mysql
rm -rf /usr/share/mysql
rm -rf /opt/mysql
rm -rf /opt/mysql/mysql-5.7.25/bin/mysql
rm -rf /opt/mysql/mysql-5.7.25/include/mysql
rm -rf /opt/mysql/mysql-5.7.25/data/mysq

参见原文链接:

https://blog.csdn.net/qq_31708763/article/details/86485398

安装参考原文:

https://www.cnblogs.com/zyongzhi/p/10063149.html

原文地址:https://www.cnblogs.com/junmuc/p/12364322.html

时间: 2024-11-07 22:42:45

Linux下的 Mysql 8.0 yum 安装 并修改密码的相关文章

linux下nginx,mysql,php(lnmp)编译安装

关闭SELINUX vi /etc/selinux/config #SELINUX=enforcing #注释掉 #SELINUXTYPE=targeted #注释掉 SELINUX=disabled #增加 :wq!  #保存退出 setenforce 0 #使配置立即生效 mysql 5.5.28安装 安装路径:/usr/local/mysql数据库路径:/usr/local/mysql/data/ mysql从5.5版本开始,不再使用./configure编译,而是使用cmake编译器,具

Linux下查看mysql、apache是否安装,安装,卸载等操作

Linux下查看mysql.apache是否安装,并卸载. 指令 ps -ef|grep mysql 得出结果 root     17659     1  0  2011 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --log-error=/var/log/mysqld.log --pid-file=/var/run/mysql

macOS 下的 MySQL 8.0.17 安装与简易配置

如果我写的这篇你看不懂,可能网上也没有你能看懂的教程了 虽然这篇针对的是8.0.x版本,但是关于MySQL配置之类的方法还是通用的 环境信息与适用范围 环境信息 环境/软件 版本 macOS macOS Mojave MySQL MySQL 8.0.17 适用范围 环境/软件 版本 macOS macOS大概都行吧 MySQL 8.0.x 第零步,清除之前的MySQL ( 除非你想装多个版本 ) 打开终端,输入以下??代码,并执行 sudo rm /usr/local/mysql sudo rm

Linux下查看MySQL的安装路径

Linux下查看mysql.apache是否安装,并卸载. 指令 ps -ef|grep mysql 得出结果 root     17659     1  0  2011 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --log-error=/var/log/mysqld.log --pid-file=/var/run/mysql

linux 下配置mysql区分大小写(不区分可能出现找不到表的情况)怎么样使用yum来安装mysql

Linux 默认情况下,数据库是区分大小写的:因此,要将mysql设置成不区分大小写 在my.cof 设置 lower_case_table_names=1(1忽略大小写,0区分大小写) 检查方式:在mysql控制台中输入如下命令 show variables like 'lower%'; linux下查找mysql安装路径: whereis mysql yum 安装mysql: linux下使用yum安装mysql,以及启动.登录和远程访问. 1.安装 查看有没有安装过: yum list i

Linux下WebSphereV8.5.5.0 安装详细过程

Linux下WebSphereV8.5.5.0 安装详细过程 自WAS8以后安装包不再区别OS,一份介质可以安装到多个平台.只针对Installation Manager 进行了操作系统的区分 ,Websphere产品介质必须通过专门的工具Install Managere安装.进入IBM的官网http://www.ibm.com/us/en/进行下载.在云盘http://yun.baidu.com/share/linkshareid=2515770728&uk=4252782771 中是Linu

Linux下PHP+MySQL+CoreSeek中文检索引擎配置

说明: 操作系统:CentOS 5.X 服务器IP地址:192.168.21.127 Web环境:Nginx+PHP+MySQL 站点根目录:/usr/local/nginx/html 目的:安装coreseek中文检索引擎,配置MySQL数据库访问接口,使用PHP程序实现中文检索. CoreSeek官方网站: http://www.coreseek.cn/ http://www.coreseek.cn/products/=%22/products-install/step_by_step/ h

Linux下的Mysql初步认实和搭建LAMP环境

Linux下的Mysql初步认实和搭建LAMP环境   实验目标 Mysql服务器常见概念 Mysql服务器安装及相关配置文件 实战:安装mysql数据库并去除安全隐患 实战:搭建LAMP环境部署Ucenter和Ucenter-home网站   实验概述 MySQL服务概述: MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司. MySQL是最流行的关系型数据库管理系统,在WEB应用方面MySQL是最好的RDBMS(Relational Databas

linux下编译qt5.6.0静态库——configure配置

 随笔 - 116  文章 - 4  评论 - 7 linux下编译qt5.6.0静态库--configure配置 linux下编译qt5.6.0静态库 linux下编译qt5.6.0静态库 configure生成makefile 安装选项 Configure选项 第三方库: 附加选项: QNX/Blackberry选项: Android 选项: 生成makefile 遇到链接检查失败的情况 生成makefile后进行编译 编译时的错误 多重定义'QT_MODBUS()'和'QT_MODBU