1. 程式人生 > >CentOS6.8 安裝Mysql資料庫

CentOS6.8 安裝Mysql資料庫

概述

 1. 檢視系統中是否已經自帶Mysql資料庫
 2. 使用yum命令進行Mysql的安裝
 3. Mysql資料庫的初始化及相關配置
 4. 遠端連線Mysql及授權

1.檢視系統中是否已經自帶Mysql資料庫

[root@Sunzh ~]# rpm -qa | grep mysql   //檢視是否已經安裝了Mysql
mysql-libs-5.1.73-8.el6_8.x86_64
[root@Sunzh ~]# rpm -e mysql           //普通刪除
error: package mysql is not installed
[root@Sunzh
~]# rpm -e --nodeps mysql //強制刪除 error: package mysql is not installed

2. 使用yum命令進行Mysql的安裝

[[email protected] ~]# yum list | grep mysql  //檢視yum上提供下載的mysql的版本資訊
mysql-libs.x86_64                             5.1.73-8.el6_8               @base
apr-util-mysql.x86_64                         1.3
.9-3.el6_0.1 base asterisk-mysql.x86_64 1.8.32.3-2.el6 epel bacula-director-mysql.x86_64 5.0.0-13.el6 base bacula-storage-mysql.x86_64 5.0.0-13.el6 base collectd-mysql.x86_64 4.10
.9-5.el6 epel dmlite-plugins-mysql.x86_64 1.10.3-1.el6 epel dovecot-mysql.x86_64 1:2.0.9-22.el6 base dpm-copy-server-mysql.x86_64 1.10.0-5.el6 epel dpm-name-server-mysql.x86_64 1.10.0-5.el6 epel dpm-server-mysql.x86_64 1.10.0-5.el6 epel dpm-srm-server-mysql.x86_64 1.10.0-5.el6 epel .........
[root@Sunzh ~]# yum install -y mysql-server mysql mysql-deve   //安裝資料庫
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
No package mysql-deve available.
Resolving Dependencies
.........
[[email protected] ~]# rpm -qi mysql-server   //檢視資料庫版本等資訊
Name        : mysql-server                 Relocations: (not relocatable)
Version     : 5.1.73                            Vendor: CentOS
Release     : 8.el6_8                       Build Date: Fri 27 Jan 2017 06:25:43 AM CST
Install Date: Fri 03 Aug 2018 10:23:55 AM CST      Build Host: c1bm.rdu2.centos.org
Group       : Applications/Databases        Source RPM: mysql-5.1.73-8.el6_8.src.rpm
Size        : 25884131                         License: GPLv2 with exceptions
Signature   : RSA/SHA1, Fri 27 Jan 2017 06:35:28 AM CST, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://www.mysql.com
Summary     : The MySQL server and related files
Description :
MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. This package contains
the MySQL server and some accompanying files and directories.

3. Mysql資料庫的初始化及相關配置

[[email protected] ~]# service mysqld start   //第一次啟動mysql服務,首先會進行初始化的配置
Initializing MySQL database:  WARNING: The host 'Sunzh' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK
.........
[root@Sunzh ~]# service mysqld start   //第二次不會
Starting mysqld:                                           [  OK  ]

設定開機自動啟動

[root@Sunzh ~]# chkconfig --list | grep mysqld //未設定前的狀態
mysqld          0:off   1:off   2:off   3:off   4:off   5:off   6:off

[root@Sunzh ~]# chkconfig mysqld on            //設定開機啟動

[root@Sunzh ~]# chkconfig --list | grep mysqld //設定後的狀態
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
[[email protected] ~]# mysqladmin -u root password 'root' //第一次設定密碼
[[email protected] ~]# mysql -u root -p   //登陸mysql伺服器,密碼是上面設定的root
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
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>

4. 遠端連線Mysql及授權

mysql> show databases;      //檢視所有資料庫
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)
mysql> use mysql;       //使用mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;     //顯示所有的表
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
23 rows in set (0.00 sec)
mysql> select Host,User,Password from user\G;   //檢視賬戶
*************************** 1. row ***************************
    Host: localhost
    User: root
Password: *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B
*************************** 2. row ***************************
    Host: sunzh
    User: root
Password:
*************************** 3. row ***************************
    Host: 127.0.0.1
    User: root
Password:
*************************** 4. row ***************************
    Host: localhost
    User:
Password:
*************************** 5. row ***************************
    Host: sunzh
    User:
Password:
5 rows in set (0.00 sec)
mysql> grant all privileges on *.* to [email protected]'%' identified by "root";    //授權
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;    //重新整理
Query OK, 0 rows affected (0.00 sec)
mysql> select Host,User,Password from user\G;   //再次檢視賬號,多了第六條
*************************** 1. row ***************************
    Host: localhost
    User: root
Password: *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B
*************************** 2. row ***************************
    Host: sunzh
    User: root
Password:
*************************** 3. row ***************************
    Host: 127.0.0.1
    User: root
Password:
*************************** 4. row ***************************
    Host: localhost
    User:
Password:
*************************** 5. row ***************************
    Host: sunzh
    User:
Password:
*************************** 6. row ***************************//%所有IP都可以訪問
    Host: %
    User: root
Password: *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B
6 rows in set (0.00 sec)

Navicat測試連線
這裡寫圖片描述

注意:
服務需要開放3306埠,阿里雲和騰訊雲是在控制檯新增防火牆規則的
這裡寫圖片描述

相關推薦

CentOS6.8 安裝Mysql資料庫

概述 1. 檢視系統中是否已經自帶Mysql資料庫 2. 使用yum命令進行Mysql的安裝 3. Mysql資料庫的初始化及相關配置 4. 遠端連線Mysql及授權 1.檢視系統中是否已經自帶Mysql資料庫 [root@Sunzh

CentOS6.8 安裝 mysql 5.6

mysqld root用戶 tar mysql56 無法執行 lease name sql var 安裝前的準備: 1、確認是否安裝過mysql: yum list installed | grep mysql 2、刪除系統自帶的mysql及

centos6.8安裝mysql並配置遠程登陸

配置 server ack span body 改密 mmu pos spa 1.wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm 2.yum install mysql-community-re

CentOS6離線安裝mysql資料庫

第一步:這裡我們需要根據我們的作業系統版本下載資料庫:CentOS_6下載:mysql-5.7.22-1.el6.x86_64.rpm-bundle.tarCentOS_7下載:mysql-5.7.17-1.el7.x86_64.rpm-bundle.tar截圖:第二步:將下

阿里雲centos6.5 安裝mysql資料庫

一、解除安裝掉原有的mysql   1.檢視系統上是否安裝mysql     rpm -qa | grep mysql  // 這個命令就會檢視該作業系統上是否已經安裝了mysql資料庫     如果有的話就使用 rpm -e 命令 或者 rpm -e --nodeps 命令來解除安裝掉。     r

CentOS6.8 x86_64bit mysql-5.5.57多實例安裝

app amp 啟動 install 創建 part evel read .tar.gz mysql多實例安裝註意:提前下載保存mysql-5.5.57的軟件包與cmake編譯mysql的工具ll /home/rich/toolsmysql-5.5.57.tar.gz

centos6安裝mysql資料庫

以下博文參照 https://www.linuxidc.com/Linux/2016-09/135288.htm   centos7安裝 1.檢測系統是否已經安裝過mysql或其依賴,若已裝過要先將其刪除,否則第4步使用yum安裝時會報錯: 1 # yum list

Centos6安裝CDH5.15.1最詳細版-3 安裝Mysql資料庫

安裝Mysql 安裝包為:MySQL-5.6.41-1.el6.x86_64.rpm-bundle.tar 下載完成後上傳伺服器: 解壓tar包,並新增執行許可權 ## 解壓tar包 tar -xvf MySQL-5.6.41-1.el6.x86_64

centos6.8安裝Elasticsearch和Kibana

elasticsearch kibana 註: Elasticsearch Kibana 的下載地址統一為https://www.elastic.co/downloads/需要相應的安裝軟件可以加本人微信:WJT1356973472(戰神)一:安裝Elasticsearch下載elasticsear

CentOS6.8 安裝配置以svnadmin管理svn代碼庫

http管理svn庫 svnadmin一、系統環境及說明CentOS6.8_X64subversion版本 1.8.15svn是版本控制軟件,雖然git大用替代它的趨勢,但不可否則還有很多老用戶喜歡它,及svn有一個好用的功能hooks鉤子功能。後面再說這個hooks的用處。1、準備repo$cat /etc

CentOS6.8安裝mongodb3.0並添加到系統服務

腳本 mongodb 一、系統環境CentOS 6.8_x64官方參考文檔https://docs.mongodb.org/manual/reference/glossary/#term-init-script二、添加官方yum庫#cd /etc/yum.repo.d/#vim mongodb.re

()centos6.8安裝配置ftp服務器

服務 配置ftp服務器 () 控制 原理 文件結構 連接 centos6 安裝 ftp傳輸原理 客戶端通過某軟件用某個端口(a端口)向服務端發起tcp連接請求,同時告訴服務端客戶端另一個空閑端口號(b端口),服務端用21端口與客戶端建立一條控制連接通道。 接著在默認情況下,

CentOS6.8安裝360 pika

fig snap ref dconf get span tar 存在 下載 1、安裝依賴包 yum install snappy-devel bz2 libzip-dev libsnappy-dev libprotobuf-dev libevent-dev protobu

Centos6.5安裝mysql

ice .cn tab scrip bar 麻煩 repo vda messages CentOS6.5安裝與配置Mysql數據庫 時間:2014-12-11 02:11來源:Bmmboo 作者:Bmmboo 舉報 點擊:74545次 一、mysql簡介 說到數據庫,

centos6.8 安裝jdk

mode 分別是 ssp 自帶 col 官網下載 個人 color 添加 一、卸載CentOS自帶的Java 1. 查看CentOS的Java的信息 [[email protected] /]# java -version java version

CentOS6.8安裝Python3.6.3

blog com spa tool linux prefix org oca 下載 1、linux下安裝python3 準備編譯環境(環境如果不對的話,可能遇到各種問題,比如wget無法下載https鏈接的文件) yum install zlib-devel bzip2

centos6.8安裝lnmp

安裝 wget libxml pan 發包 class centos openssl pcre 一、配置CentOS 第三方yum源(CentOS默認的標準源裏沒有nginx軟件包) [root@localhost ~]# yum install wget

CentOS6.8 安裝 Nginx

分享 性能 sys openss cto ann share 狀態 ssl 一、Nginx簡介 Nginx是一個web服務器也可以用來做負載均衡及反向代理使用,目前使用最多的就是負載均衡,具體簡介我就不介紹了百度一下有很多,下面直接進入安裝步驟 二、Nginx安裝 1

CentOS6.8安裝seafile

下載 mkdir open admin red fig log mirror pill 有問題,有官網測試過的Linux平臺:https://www.seafile.com/download/ 一、安裝python2.7.141、安裝依賴包[root@web01 ~]# y

Centos6.8安裝mysql5.6

通用二進制 讀取 x86 comm less chm partprobe part ice 安裝環境:CentOS 6.8 目的:通過通用二進制(Generic Binary)的方式安裝MySQL5.6.16所需軟件:mysql-5.6.16-linux-glibc2.5-