linux mysql升级8,Java面试题库

1.3解压

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

2.删除原mysql

2.1查询安装的mysql并删除

rpm -qa |grep mysql -i

查询出来的都删除

rpm -e --nodeps ***

2.2删除残余

whereis mysql

查询出来的都删除

rm -rf /usr/bin/mysql /usr/lib64/mysql /usr/share/man/man1/mysql.1.gz

2.3删库(2.4不是跑路,因为之前安装过mysql,如果之前没有安装过,不用清理)

rm -rf /var/lib/mysql

2.4.删除日志(只安装不启动这个文件有,但是文件是没有内容的)

rm -rf /var/log/mysqld.log

3.安装

3.1安装必选项(按照顺序,我是一次性安装的,和分开安装没啥区别,省事儿一点)

首先安装common

然后安装lib

接着安装client

最后安装server

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

如果有报错

error: Failed dependencies:

perl(JSON) is needed by mysql-community-test-8.0.15-1.el7.x86_64

解决方案:

yum install perl.x86_64 perl-devel.x86_64 -y

yum install perl-JSON.noarch -y

3.2 安装非必选项(可不安装,按照顺序)

rpm -ivh mysql-community-libs-compat-8.0.15-1.el7.x86_64.rpm

rpm -ivh mysql-community-embedded-compat-8.0.15-1.el7.x86_64.rpm

rpm -ivh mysql-community-devel-8.0.15-1.el7.x86_64.rpm

rpm -ivh mysql-community-test-8.0.15-1.el7.x86_64.rpm

安装完成

4.启动

4.1启动mysql

sevice mysqld start

5.设置密码

不修改密码登录后是不能操作的

例如:

mysql> use mysql

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

修改密码有两种方式

1.利用生成的出手四化密码登录,然后修改

初始化密码在/var/log/mysqld.log

例如:

2019-05-31T02:08:01.273665Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.15) initializing of server in progress as process 91249

2019-05-31T02:08:03.665256Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: j)n,?QEJu9ju

2019-05-31T02:08:05.810755Z 0 [System] [MY-013170] [Server] /usr/sbin/mysqld (mysqld 8.0.15) initializing of server has completed

2019-05-31T02:08:08.600324Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.15) starting as process 91400

2019-05-31T02:08:12.134663Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.

2019-05-31T02:08:12.221291Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: ‘8.0.15’ socket: ‘/var/lib/mysql/mysql.sock’ port: 3306 MySQL Community Server - GPL.

2019-05-31T02:08:12.294986Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: ‘/var/run/mysqld/mysqlx.sock’ bind-address: ‘::’ port: 33060

“j)n,?QEJu9ju”就是初始化的密码(不带前面的空格)

《一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》

【docs.qq.com/doc/DSmxTbFJ1cmN1R2dB】 完整内容开源分享

利用初始化密码登录

mysql -uroot -p初始化密码

修改密码

ALTER user ‘root’@‘localhost’ IDENTIFIED BY ‘Admin@123’

2.关闭密码登录,无密码登录后修改密码

vi /etc/my.cnf

添加skip-grant-tables(添加之后登陆不需要密码)

重启

sevice mysqld start

登陆

直接mysql -uroot -p

Enter

即可登录

登录后修改密码:

ALTER user ‘root’@‘localhost’ IDENTIFIED BY ‘Admin@123’

密码必须复杂,123456是设置不成的

6.开启远程访问

登录mysql

mysql -uroot -p修改后的密码

选择mysql数据库

use mysql

允许远程访问

update user set host = ‘%’ where user = ‘root’;

你可能感兴趣的:(程序员,面试,java,后端)