千家信息网

mysql怎么样进行安装

发表于:2025-11-07 作者:千家信息网编辑
千家信息网最后更新 2025年11月07日,这篇文章主要为大家展示了"mysql怎么样进行安装",内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下"mysql怎么样进行安装"这篇文章吧。一、下载安装包1,下
千家信息网最后更新 2025年11月07日mysql怎么样进行安装

这篇文章主要为大家展示了"mysql怎么样进行安装",内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下"mysql怎么样进行安装"这篇文章吧。

一、下载安装包

1,下载hive http://mirrors.hust.edu.cn/apache/ 得到apache-hive-1.1.0.tar.gz ,放到该目录下 /home/

2,下载mysql https://dev.mysql.com/downloads/file/?id=471503得到

我的linux版本是6.8,下载时最好选择glib版本,如果下载其它各种组合包,会提示各种依赖关系,比较麻烦

拷贝到该目录下/mysql/

二、安装mysql

1.卸载系统自带的mysql相关安装包,仅卸载 mysql 开头的包

rpm -qa | grep -i mysql

rpm -ev mysql-community-libs-5.7.19-1.el7.x86_64 --nodeps

2.创建用户和组

groupadd mysql

useradd -r -g mysql mysql

3.安装

解压tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz -C ../usr/local

修改目录[root@hadoop local]# mv mysql-5.7.19-linux-glibc2.12-x86_64/ mysql

添加授权[root@hadoop mysql]# chown -R mysql.mysql /usr/local/mysql

新建data目录[root@hadoop mysql]# mkdir data

4.安装./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

注意最后一行,这也是和之有版本不同的地方,它给了root一个初始密码,此root为mysql的root用户,后面要登录的时候要用到这个密码。#H#,?*Els4G&

4.将mysql/目录下除了data/目录的所有文件,改回root用户所有,mysql用户只需作为mysql/data/目录下所有文件的所有者。

[root@hadoop mysql]# chown -R root .

[root@hadoop mysql]# chown -R mysql data

5.创建tmp文件夹,并授权

[root@hadoop mysql]# mkdir tmp

[root@hadoop mysql]# chown -R mysql:mysql tmp

6.复制并编辑配置文件

[root@hadoop etc]# cp my.cnf.rpmsave my.cnf

[root@hadoop etc]# vi my.cnf

7.添加以下内容

basedir = /usr/local/mysql

datadir = /usr/local/mysql/data

port = 3306

socket = /usr/local/mysql/tmp/mysql.sock

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

8.将mysql.server拷贝到/etc/init.d/mysql

[root@hadoop support-files]# cp mysql.server /etc/init.d/mysql

[root@hadoop init.d]# chmod +x mysql

9.把mysql注册为开机启动的服务
[root@hadoop init.d]# chkconfig --add mysql

[root@hadoop init.d]# chkconfig --list mysql

mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off

10.启动

[root@hadoop init.d]# /etc/init.d/mysql start

Starting MySQL.Logging to '/usr/local/mysql/data/hadoop.err'.

. [ OK ]

11.修改环境变量

export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:/usr/local/mysql:/usr/local/mysql/bin

[root@hadoop init.d]# source /etc/profile

12.使用root登录时报错

[root@hadoop init.d]# mysql -uroot -p #H#,?*Els4G&

Enter password:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

13.修改 /etc/my.cnf文件,补充mysql和client配置

[mysqld]

basedir = /usr/local/mysql

datadir = /usr/local/mysql/data

port = 3306

socket = /usr/local/mysql/tmp/mysql.sock

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

skip-grant-tables

[mysql]

default-character-set=utf8

socket = /usr/local/mysql/tmp/mysql.sock

[client]

default-character-set=utf8

socket = /usr/local/mysql/tmp/mysql.sock

14.重新登录,并输入新密码

[root@hadoop etc]# mysql -uroot -p #H#,?*Els4G&

Enter password: mysql

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.7.19 MySQL Community Server (GPL)

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

15.mysql服务的开启和关闭

#/etc/init.d/mysql start 或者 serivce mysql start 或者 bin/mysqld_safe&

#/etc/init.d/mysql stop 或者 service mysql stop 或者 bin/mysqladmin -uroot -p

三、添加hive用户,会提示如下错误

mysql> create user 'hive'@'%' identified by 'hive';

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

强制写出

mysql> flush privileges;

重新执行

mysql> create user 'hive'@'%' identified by 'hive';

Query OK, 0 rows affected (0.00 sec)

mysql> select host,user from user;

+-----------+---------------+

| host | user |

+-----------+---------------+

| % | hive |

| localhost | mysql.session |

| localhost | mysql.sys |

| localhost | root |

+-----------+---------------+

4 rows in set (0.00 sec)

以上是"mysql怎么样进行安装"这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!

目录 文件 用户 内容 版本 篇文章 登录 密码 拷贝 学习 帮助 提示 服务 配置 不同 一行 变量 只需 地方 开头 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 pc机上运行数据库 安徽工程软件开发项目经理 数据库用的是什么工具 10月12日国家网络安全 西城区制造软件开发规定 unity 服务器管理 华为服务器怎么设置风扇 武汉商贸职业学院网络技术 U8重新启动数据库 xftp远程服务器连接工具 工科类外文文献数据库网站 南昌网络安全员招聘 天翼云服务器安全卫士风险分析 ovs数据库备份 网络安全和信息化评论员文章 我的世界搭建的服务器别人进不了 学习网络技术需要什么基础知识 网络安全运营服务工程师岗位 北京有哪些做软件开发的公司 上海智慧门禁软件开发机构 winpe下软件开发工具 emq服务器mqtt消息延时 苏州智喵互联网络科技有限公司 还可以打开服务器的老游戏 北辰区企业网络技术诚信合作 大连锡林软件开发服务中心 网络安全知识竞赛APP ftp服务器软件安全吗 数据库常用部署架构 渝北区提供网络技术活动方案
0