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