?
1、檢查是否有安裝
[root@JDDB mysql]# yum list installed | grep mysql
mysql-community-client.x86_64 ? ? ? ?5.6.39-2.el7 ? ? ? ? ? ? ? ? ? @mysql56-community
mysql-community-common.x86_64 ? ? ? ?5.6.39-2.el7 ? ? ? ? ? ? ? ? ? @mysql56-community
mysql-community-libs.x86_64 ? ? ? ? ?5.6.39-2.el7 ? ? ? ? ? ? ? ? ? @mysql56-community
mysql-community-release.noarch ? ? ? el7-5 ? ? ? ? ? ? ? ? ? ? ? ? ?installed ??
mysql-community-server.x86_64 ? ? ? ?5.6.39-2.el7 ? ? ? ? ? ? ? ? ? @mysql56-community
2、卸載刪除
[root@JDDB mysql]# yum -y remove mysql-community-*
?
同類文章:
http://blog.csdn.net/zengmingen/article/details/52326253
?
以root賬號登錄完成以下操作
?
1、修改yum為阿里云的(可選),修改后下載快。
方法見博文:http://blog.csdn.net/zengmingen/article/details/52956276
?
2、使用yum安裝mysql server。
?
yum install -y mysql-server
如果提示未找到?mysql-server,使用下面的步驟:
?
?
下載 MySQL Yum Repository
https://repo.mysql.com/
地址為?http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
執行
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
如果提示
-bash: wget: 未找到命令
,請先執行?yum install wget
?安裝 wget
安裝
添加 MySQL Yum Repository
添加?MySQL?Yum Repository 到你的系統 repository 列表中,執行
yum localinstall mysql-community-release-el7-5.noarch.rpm
顯示
[root@bogon software]# yum localinstall mysql-community-release-el7-5.noarch.rpm
已加載插件:fastestmirror
正在檢查 mysql-community-release-el7-5.noarch.rpm: mysql-community-release-el7-5.noarch
mysql-community-release-el7-5.noarch.rpm 將被安裝
正在解決依賴關系
--> 正在檢查事務 ---> 軟件包 mysql-community-release.noarch.0.el7-5 將被 安裝 --> 解決依賴關系完成 依賴關系解決 ================================================================================ Package 架構 版本 源 大小 ================================================================================ 正在安裝: mysql-community-release noarch el7-5 /mysql-community-release-el7-5.noarch 4.3 k 事務概要 ================================================================================ 安裝 1 軟件包 總計:4.3 k 安裝大小:4.3 k Is this ok [y/d/N]
提示是否 OK ,輸入 y
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction正在安裝 : mysql-community-release-el7-5.noarch 1/1驗證中 : mysql-community-release-el7-5.noarch 1/1已安裝:mysql-community-release.noarch 0:el7-5完畢!
提示“完成!”,則說明 源添加成功。
驗證下是否添加成功
yum repolist enabled | grep "mysql.*-community.*"
可以看到下面內:
[root@bogon software]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community 1
mysql-tools-community/x86_64 MySQL Tools Community 1
mysql56-community/x86_64 MySQL 5.6 Community Server 13
選擇要啟用 MySQL 版本
查看 MySQL 版本,執行
yum repolist all | grep mysql
可以看到 5.5, 5.7 版本是默認禁用的,因為現在最新的穩定版是 5.6
[root@bogon software]# yum repolist all | grep mysql
mysql-connectors-community/x86_64 MySQL Connectors Community 啟用: 14
mysql-connectors-community-source MySQL Connectors Community - Sourc 禁用
mysql-tools-community/x86_64 MySQL Tools Community 啟用: 17
mysql-tools-community-source MySQL Tools Community - Source 禁用
mysql55-community/x86_64 MySQL 5.5 Community Server 禁用
mysql55-community-source MySQL 5.5 Community Server - Sourc 禁用
mysql56-community/x86_64 MySQL 5.6 Community Server 啟用: 139
mysql56-community-source MySQL 5.6 Community Server - Sourc 禁用
mysql57-community-dmr/x86_64 MySQL 5.7 Community Server Develop 禁用
mysql57-community-dmr-source MySQL 5.7 Community Server Develop 禁用
?
?
?
通過 Yum 來安裝 MySQL
執行
yum install mysql-server
Yum 會自動處理 MySQL 與其他組件的依賴關系:
---------------------------------------
如果報錯,內容含有
Error: Package: mysql-community-libs-5.6.35-2.el7.x86_64 (mysql56-community)Requires: libc.so.6(GLIBC_2.17)(64bit)
Error: Package: mysql-community-server-5.6.35-2.el7.x86_64 (mysql56-community)Requires: libc.so.6(GLIBC_2.17)(64bit)
Error: Package: mysql-community-server-5.6.35-2.el7.x86_64 (mysql56-community)Requires: systemd
Error: Package: mysql-community-server-5.6.35-2.el7.x86_64 (mysql56-community)Requires: libstdc++.so.6(GLIBCXX_3.4.15)(64bit)
Error: Package: mysql-community-client-5.6.35-2.el7.x86_64 (mysql56-community)Requires: libc.so.6(GLIBC_2.17)(64bit)You could try using --skip-broken to work around the problemYou could try running: rpm -Va --nofiles --nodigest
- ?
解決:
#yum install glibc.i686
# yum list libstdc++*
解決方法二
#cd /etc/yum.repos.d/
-
#sudo vi mysql-community.repo
- ?
-
找到mysql-56-community
- ?
-
將enable置為0 enable=0
-
重新安裝mysql sudo yum install mysql-server
?
--------------------------------------------
service mysqld start ? ? ? ?//沒錯就是這么變態,沒有i,mysql+d
chkconfig mysqld on ? ? ? ?//沒錯就是這么變態,沒有i,mysql+d
?
3、給mysql root用戶修改密碼
設置MySQL 數據庫root 用戶的密碼: ?
# mysqladmin -u root password '123456' ?
登錄數據庫: ?
# mysql -u root -p ?
輸入密碼
MySQL 授權遠程訪問 (先用root 登錄mysql) ?
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '654321' WITH ?
GRANT OPTION; ?
mysql> FLUSH PRIVILEGES; ?
注意:本地登錄和遠程登錄的密碼是可以分開的,最好設置為不同
如果不要修改:
linux的root用戶輸入mysql。
-----mysql默認設置了root用戶和密碼。
-----Linux的root用戶輸入mysql的時候,會默認登陸root,無需輸入用戶名和密碼
4、在mysql上創建用戶
此處演示創建hive元數據庫,并對hive用戶進行授權
//創建數據庫
create database if not exists hive_metadata;
?
//創建用戶hive,密碼hive,把賦予全部權限和允許任意機器遠程訪問(@'%' 'localhost''本機hosts名')
//hive_metadata 是hive數據庫名
?
grant all privileges on hive_metadata.* to 'hive'@'%' identified by 'hive';
grant all privileges on hive_metadata.* to 'hive'@'localhost' identified by 'hive';
grant all privileges on hive_metadata.* to 'hive'@'本機hosts名' identified by 'hive';
?
//刷新權限
flush privileges;
?
--------以上就已經完成了mysql的安裝和創建數據庫和用戶--------------
--------現在以Linux非root用戶登陸mysql
演示以hadoop用戶登陸
[hadoop@BD05 ~]$ mysql -uhive -phive
Welcome to the MySQL monitor. ?Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, 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> show databases;
+--------------------+
| Database ? ? ? ? ? |
+--------------------+
| information_schema |
| hive_metadata ? ? ?|
| test ? ? ? ? ? ? ? |
+--------------------+
3 rows in set (0.00 sec)
?
?