二進位包安裝MySQL資料庫

来源:http://www.cnblogs.com/hackerer/archive/2016/03/18/5294092.html
-Advertisement-
Play Games

1.1二進位包安裝MySQL資料庫 1.1.1 安裝前準備(規範) 1.1.2 初始化資料庫 1.1.3 授權Mysql管理資料庫文件 1.1.4 生成Mysql配置文件 1.1.5 配置啟動Mysql 1.1.6 啟動Mysql 1.1.7 配置環境變數 方法1: 方法2: 1.1.8 設置及更改


1.1二進位包安裝MySQL資料庫

1.1.1 安裝前準備(規範)

 

 1 [root@Mysql_server ~]# mkdir -p /home/zhurui/tools  ##創建指定工具包存放路徑
 2 [root@Mysql_server ~]# wget http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.5/mysql-5.5.32-linux2.6-x86_64.tar.gz  ##下載二進位包
 3 [root@Mysql_server tools]# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz   ##解壓Mysql包
 4 [root@Mysql_server tools]# useradd -s /sbin/nologin -M mysql  ##創建mysql用戶
 5 [root@Mysql_server tools]# id mysql
 6 uid=501(mysql) gid=501(mysql) groups=501(mysql)
 7 [root@Mysql_server ~]# mkdir /application/
 8 [root@Mysql_server home]# mv /home/zhurui/tools/mysql-5.5.32-linux2.6-x86_64 /application/mysql-5.5.32  
 9 [root@Mysql_server tools]# ll /application/
10 total 4
11 drwxr-xr-x. 13 root root 4096 Dec 13 14:31 mysql-5.5.32
12 [root@Mysql_server tools]# ln -s /application/mysql-5.5.32/ /application/mysql  ##設置軟鏈接
13 [root@Mysql_server tools]# ll /application/
14 total 4
15 lrwxrwxrwx.  1 root root   26 Dec 13 14:39 mysql -> /application/mysql-5.5.32/
16 drwxr-xr-x. 13 root root 4096 Dec 13 14:31 mysql-5.5.32
17 [root@Mysql_server tools]# ll /application/mysql/
18 total 76
19 drwxr-xr-x.  2 root root   4096 Dec 13 14:31 bin
20 -rw-r--r--.  1 7161 wheel 17987 Jun 19  2013 COPYING
21 drwxr-xr-x.  3 root root   4096 Dec 13 14:31 data
22 drwxr-xr-x.  2 root root   4096 Dec 13 14:30 docs
23 drwxr-xr-x.  3 root root   4096 Dec 13 14:31 include
24 -rw-r--r--.  1 7161 wheel  7470 Jun 19  2013 INSTALL-BINARY
25 drwxr-xr-x.  3 root root   4096 Dec 13 14:31 lib
26 drwxr-xr-x.  4 root root   4096 Dec 13 14:31 man
27 drwxr-xr-x. 10 root root   4096 Dec 13 14:31 mysql-test
28 -rw-r--r--.  1 7161 wheel  2496 Jun 19  2013 README
29 drwxr-xr-x.  2 root root   4096 Dec 13 14:31 scripts
30 drwxr-xr-x. 27 root root   4096 Dec 13 14:31 share
31 drwxr-xr-x.  4 root root   4096 Dec 13 14:31 sql-bench
32 drwxr-xr-x.  3 root root   4096 Dec 13 14:31 support-files

 

1.1.2 初始化資料庫

 

 1 [root@Mysql_server tools]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql  ##初始化資料庫
 2 Installing MySQL system tables...
 3 OK
 4 Filling help tables...
 5 OK
 6 [root@Mysql_server tools]# ll /application/mysql/data/  ##查看初始化結果
 7 total 12
 8 drwx------. 2 mysql root  4096 Dec 13 14:45 mysql
 9 drwx------. 2 mysql mysql 4096 Dec 13 14:45 performance_schema
10 drwxr-xr-x. 2 mysql root  4096 Dec 13 14:31 test

 

1.1.3 授權Mysql管理資料庫文件

1 [root@Mysql_server ~]# chown -R mysql.mysql /application/mysql/
2 [root@Mysql_server ~]# ll /application/mysql
3 lrwxrwxrwx. 1 mysql mysql 26 Dec 13 14:39 /application/mysql -> /application/mysql-5.5.32/

1.1.4 生成Mysql配置文件

1 [root@Mysql_server tools]# \cp /application/mysql/support-files/my-small.cnf /etc/my.cnf

1.1.5 配置啟動Mysql

1 [root@Mysql_server tools]# sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /application/mysql/support-files/mysql.server 
2 [root@Mysql_server tools]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld  ##將生成的啟動腳本拷貝到init.d目錄下
3 [root@Mysql_server tools]# chmod +x /etc/init.d/mysqld 

1.1.6 啟動Mysql

1 [root@Mysql_server tools]# lsof -i :3306  ##查詢Mysql服務是否開啟
2 [root@Mysql_server tools]# 
3 [root@Mysql_server tools]# /etc/init.d/mysqld start  ##啟動Mysql服務
4 Starting MySQL.... SUCCESS! 
5 [root@Mysql_server tools]# lsof -i :3306
6 COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
7 mysqld  2235 mysql   10u  IPv4  22761      0t0  TCP *:mysql (LISTEN)
8 [root@Mysql_server tools]# 

1.1.7 配置環境變數

方法1:

1 [root@Mysql_server tools]# cp /application/mysql/bin/* /usr/local/sbin/ ##方法1

方法2:

 

1 [root@Mysql_server tools]# tail -1 /etc/profile
2 PATH="/application/mysql/bin:$PATH"   ##尾部添加如下行
3 [root@Mysql_server tools]# source /etc/profile    ##使得配置生效

 

1.1.8 設置及更改密碼

1 [root@Mysql_server tools]# mysqladmin -uroot password 123456   
2 [root@Mysql_server tools]# mysqladmin -uroot -p123456 password zhurui

2.1 資料庫管理

 

 1 [root@Mysql_server tools]# mysql -uroot -p
 2 Enter password: 
 3 Welcome to the MySQL monitor.  Commands end with ; or \g.
 4 Your MySQL connection id is 8
 5 Server version: 5.5.32 MySQL Community Server (GPL)
 6 
 7 Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
 8 
 9 Oracle is a registered trademark of Oracle Corporation and/or its
10 affiliates. Other names may be trademarks of their respective
11 owners.
12 
13 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
14 
15 mysql> show databases;   ##查看資料庫;
16 +--------------------+
17 | Database           |
18 +--------------------+
19 | information_schema |
20 | mysql              |
21 | performance_schema |
22 | test               |
23 +--------------------+
24 4 rows in set (0.00 sec)
25 
26 mysql> drop database test;  ##刪除test庫;
27 Query OK, 0 rows affected (0.00 sec)
28 
29 mysql> show databases;    
30 +--------------------+
31 | Database           |
32 +--------------------+
33 | information_schema |
34 | mysql              |
35 | performance_schema |
36 +--------------------+
37 3 rows in set (0.00 sec)
38 
39 mysql> select user,host from mysql.user;  ##查看用戶列表;
40 +------+---------------+
41 | user | host          |
42 +------+---------------+
43 | root | 127.0.0.1     |
44 | root | ::1           |
45 |      | Mysql\_server |
46 | root | Mysql\_server |
47 |      | localhost     |
48 | root | localhost     |
49 +------+---------------+
50 6 rows in set (0.00 sec)
51 
52 mysql> drop user root@'::1';  ##刪除無用用戶
53 Query OK, 0 rows affected (0.00 sec)
54 
55 mysql> drop user ''@'Mysql\_server';      ##對於大寫、特殊字元刪除不了,下麵有介紹
56 Query OK, 0 rows affected (0.00 sec)
57 
58 mysql> drop user ''@'localhost';    
59 Query OK, 0 rows affected (0.01 sec)
60 
61 mysql> drop user 'root'@'Mysql\_server';  對於大寫、特殊字元刪除不了,下麵有介紹
62 Query OK, 0 rows affected (0.00 sec)
63 
64 mysql> select user,host from mysql.user;
65 +------+---------------+
66 | user | host          |
67 +------+---------------+
68 | root | 127.0.0.1     |
69 |      | Mysql\_server |
70 | root | Mysql\_server |
71 | root | localhost     |
72 +------+---------------+
73 4 rows in set (0.00 sec)
74 對於大寫、特殊字元刪除不瞭解決辦法:
75 mysql> delete from mysql.user where user="" and host="Mysql\_server";
76 Query OK, 1 row affected (0.02 sec)
77 
78 mysql> delete from mysql.user where user="root" and host="Mysql\_server";
79 Query OK, 1 row affected (0.00 sec)
80 
81 mysql> select user,host from mysql.user;  ##將無用用戶刪除以後,查看用戶列表                               
82 +------+-----------+
83 | user | host      |
84 +------+-----------+
85 | root | 127.0.0.1 |
86 | root | localhost |
87 +------+-----------+
88 2 rows in set (0.00 sec)
89 mysql> flush privileges;  ##最後使得許可權生效
90 Query OK, 0 rows affected (0.00 sec)

創建用戶sql語句:

 

1 mysql> grant all on *.* to 'root'@'localhost' identified by '123456' with grant option;flush privileges;

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 在伺服器A資料庫TEST新建了一個本地發佈(Local Publications)RPL_GES_MIS_TEST,在伺服器B資料庫RPL_TEST上創建了一個本地訂閱(Local Subscriptions),它訂閱了了這個發佈RPL_GES_MIS_TEST.如下截圖所示,本地發佈只有DB_OB...
  • Spark官方文檔 中文翻譯 轉載請註明出處: "http://www.cnblogs.com/BYRans/" "1 概述(Overview)" "2 引入Spark(Linking with Spark)" "3 初始化Spark(Initializing Spark)" "3.1 使用Spar
  • cubrid的中sql查詢語法insert into 官方文檔是英文的,看不明白可以參看ocracle的同類函數說明.很多都是一樣的. INSERT INTO a_tbl1(id) VALUES (4), (5); insert a single row with SET clauses INSER
  • cubrid的中sql查詢語法groupby GROUP BY ... HAVING Clause 按dept_no分組 SELECT dept_no, avg(sales_amount) FROM sales_tbl GROUP BY dept_no; 分組前先執行條件比較 SELECT dept
  • cubrid的中sql查詢語法 SELECT [ ] [{TO | INTO} ] [FROM ] [WHERE ] [GROUP BY {col_name | expr} [ASC | DESC], ...[WITH ROLLUP]] [HAVING ] [ORDER BY {col_name |
  • declare @bussHallId nvarchar(255)= '2,3' declare @strWhere nvarchar(255)= '' declare @strMain nvarchar(500) if(@bussHallId is not null) set @strWhere ...
  • 作用: 在需要引入的頭文件比較多的時候可以使用, 創建成功之後,引入頭文件.之後再使用的時候不需要引入頭文件 步驟: 1.創建一個這樣的文件 2.進行一下設置 路徑的設置 修改為yes,預編譯這個文件 3.報錯時候的解決 原因是上邊的路徑錯誤.重新設置路徑 錯誤提示
  • 本文由ilanniweb提供友情贊助,首發於爛泥行天下 想要獲得更多的文章,可以關註我的微信ilanniweb 在前一篇文章《爛泥:Postfix郵件伺服器搭建之軟體安裝與配置》中,我們介紹了psotfix郵件伺服器搭建所需要的軟體,以及各個軟體的基本配置。 目前已經達到了通過系統用戶可以登錄到po...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...