共計 3519 個字符,預計需要花費 9 分鐘才能閱讀完成。
這篇文章主要為大家展示了“mysql 怎么樣進行安裝”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓丸趣 TV 小編帶領大家一起研究并學習一下“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 怎么樣進行安裝”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注丸趣 TV 行業資訊頻道!