---------------------------------------------- 使用root登錄 1.確保服務器系統(tǒng)處于最新狀態(tài) [root@localhost ~]# yum -y update 如果顯示以下內容說明已經更新完成 Replaced: grub2.x86_64 1:2.02-0.64.el7.centos grub2-tools.x86_64 1:2.02-0.64.el7.centos Complete! 2.重啟服務器 [root@localhost ~]# reboot 3.首先檢查是否已經安裝,如果已經安裝先刪除以前版本,以免安裝不成功 [root@localhost ~]# php -v 或 [root@localhost ~]# rpm -qa | gerp mysql 或 [root@localhost ~]# yum list installed | grep mysql 如果顯示以下內容說明沒有安裝服務 -bash: gerp: command not found 4.下載MySql安裝包 [root@localhost ~]# rpm -ivh http://dev./get/mysql57-community-release-el7-8.noarch.rpm 或 [root@localhost ~]# rpm -ivh http://dev./get/mysql-community-release-el7-5.noarch.rpm 5.安裝MySql [root@localhost ~]# yum install -y mysql-server 或 [root@localhost ~]# yum install mysql-community-server 如果顯示以下內容說明安裝成功 Complete! 6.設置開機啟動Mysql [root@localhost ~]# systemctl enable mysqld.service 7.檢查是否已經安裝了開機自動啟動 [root@localhost ~]# systemctl list-unit-files | grep mysqld 如果顯示以下內容說明已經完成自動啟動安裝 mysqld.service enabled 8.設置開啟服務 [root@localhost ~]# systemctl start mysqld.service 9.查看MySql默認密碼 [root@localhost ~]# grep 'temporary password' /var/log/mysqld.log 10.登陸MySql,輸入用戶名和密碼 [root@localhost ~]# mysql -uroot -p 11.修改當前用戶密碼 mysql>SET PASSWORD = PASSWORD('Abc123!_'); 12.開啟遠程登錄,授權root遠程登錄 mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'a123456!' WITH GRANT OPTION; 13.命令立即執(zhí)行生效 mysql>flush privileges; --------------------------------------------------------------------- 其他功能: # 檢查并且顯示Apache相關安裝包 [root@localhost ~]# rpm -qa | grep mysql # 刪除MySql [root@localhost ~]# yum remove -y mysql mysql mysql-server mysql-libs compat-mysql51 或 [root@localhost ~]# rpm -e mysql-community-libs-5.7.20-1.el7.x86_64 --nodeps 或 [root@localhost ~]# yum -y remove mysql-community-libs-5.7.20-1.el7.x86_64 # 查看MySql相關文件 [root@localhost ~]# find / -name mysql # 重啟MySql服務 [root@localhost ~]# service mysqld restart # 查看MySql版本 [root@localhost ~]# yum repolist all | grep mysql # 查看當前的啟動的 MySQL 版本 [root@localhost ~]# yum repolist enabled | grep mysql # 通過Yum來安裝MySQL,會自動處理MySQL與其他組件的依賴關系 [root@localhost ~]# yum install mysql-community-server # 查看MySQL安裝目錄 [root@localhost ~]# whereis mysql # 啟動MySQL服務 [root@localhost ~]# systemctl start mysqld # 查看MySQL服務狀態(tài) [root@localhost ~]# systemctl status mysqld # 關閉MySQL服務 [root@localhost ~]# systemctl stop mysqld # 測試MySQL是否安裝成功 [root@localhost ~]# mysql # 查看MySql默認密碼 [root@localhost ~]# grep 'temporary password' /var/log/mysqld.log # 查看所有數(shù)據(jù)庫 mysql>show databases; # 退出登錄數(shù)據(jù)庫 mysql>exit; # 查看所有數(shù)據(jù)庫用戶 mysql>SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
|
|
來自: wwq圖書世界 > 《java環(huán)境》