Hive基础知识(三):Linux系统下的MySQL安装

发布时间:2024年01月09日

?1)检查当前系统是否安装过 MySQL

[zzdq@hadoop100 hive]$ rpm -qa|grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
#如果存在,就用下面这条命令卸载
[zzdq@hadoop100 hive]$ sudo rpm -e --nodeps mariadb-libs

?2)解压 MySQL 安装包

[zzdq@hadoop100 ~]$ tar -xf mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar -C /opt/software/
[zzdq@hadoop100 software]$ ll
总用量595272
drwxr-xr-x 11 zzdq zzdq 233 12月16 08:26 hadoop-2.7.2
-rw-r--r--1 zzdq zzdq 45109364 9月30 2019 mysql-community-client-5.7.28-1.el7.x86_64.rpm
-rw-r--r--1 zzdq zzdq 318768 9月30 2019 mysql-community-common-5.7.28-1.el7.x86_64.rpm
-rw-r--r--1 zzdq zzdq 7037096 9月30 2019 mysql-community-devel-5.7.28-1.el7.x86_64.rpm
-rw-r--r--1 zzdq zzdq 49329100 9月30 2019 mysql-community-embedded-5.7.28-1.el7.x86_64.rpm
-rw-r--r--1 zzdq zzdq 23354908 9月30 2019 mysql-community-embedded-compat-5.7.28-1.el7.x86_64.rpm
-rw-r--r--1 zzdq zzdq 136837816 9月30 2019 mysql-community-embedded-devel-5.7.28-1.el7.x86_64.rpm
-rw-r--r--1 zzdq zzdq 4374364 9月30 2019 mysql-community-libs-5.7.28-1.el7.x86_64.rpm
-rw-r--r--1 zzdq zzdq 1353312 9月30 2019 mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm
-rw-r--r--1 zzdq zzdq 208694824 9月30 2019 mysql-community-server-5.7.28-1.el7.x86_64.rpm
-rw-r--r--1 zzdq zzdq 133129992 9月30 2019 mysql-community-test-5.7.28-1.el7.x86_64.rpm

3)在安装目录下执行 rpm 安装

sudo yum install -y libaio
sudo rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-client-5.7.28-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm
云服务器安装
sudo yum install -y libaio
sudo yum -y install numactl
sudo rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm --force --nodeps
sudo rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm --force --nodeps
sudo rpm -ivh mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm --force --nodeps
sudo rpm -ivh mysql-community-client-5.7.28-1.el7.x86_64.rpm --force --nodeps
sudo rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm --force --nodeps

注意:按照顺序依次执行如果 Linux 是最小化安装的,在安装 mysql-community-server-5.7.28-1.el7.x86_64.rpm 时可能会出现如下错误

5)删除/etc/my.cnf 文件中 datadir 指向的目录下的所有内容,如果有内容的情况下:

查看 datadir 的值:

datadir=/var/lib/mysql

删除/var/lib/mysql 目录下的所有内容:?

[zzdq @hadoop102 mysql]# cd /var/lib/mysql?
[zzdq @hadoop102 mysql]# sudo rm -rf ./*//注意执行命令的位置

6)初始化数据库

[zzdq@hadoop100 software]$ sudo mysqld --initialize --user=mysql

?7)查看数据生成的临时密码

[zzdq@hadoop100 software]$ sudo cat /var/log/mysqld.log
2021-12-16T04:00:41.379764Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-12-16T04:00:41.555275Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-12-16T04:00:41.585421Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-12-16T04:00:41.644727Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: bc871a78-5e24-11ec-8bb9-000c291b1228.
2021-12-16T04:00:41.655476Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-12-16T04:00:42.193117Z 0 [Warning] CA certificate ca.pem is self signed.
2021-12-16T04:00:42.380448Z 1 [Note] A temporary password is generated for root@localhost: cuF/svfFG6:#

?8)启动 MySQL 服务

[zzdq @hadoop102 opt]$ sudo systemctl start mysqld

?9)登录 MySQL 数据库

[zzdq @hadoop102 opt]$ mysql -uroot -p?
Enter password: 输入临时生成的密码

10)必须先修改 root 用户的密码,否则执行其他的操作会报错

mysql> set password = password("新密码");?

11)修改 mysql 库下的 user 表中的 root 用户允许任意 ip 连接

mysql> update mysql.user set host='%' where user='root';
Query OK,1 row affected (0.00 sec)
Rows matched: 1 ?Changed: 1 ?Warnings: 0

mysql> flush privileges;
Query OK,0 rows affected (0.01 sec)


?

文章来源:https://blog.csdn.net/zuodingquan666/article/details/135448543
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。