Linux 平臺下 MySQL 5.5 安裝 說明 與 示例

?

一.下載說明

前期的一些準備說明,參考:

MySQL 發展史

http://blog.csdn.net/tianlesoftware/article/details/6999245

?

Mysql 不同版本 說明

http://blog.csdn.net/tianlesoftware/article/details/6723117

MySQL 分為Community Server 和 Enterprise Edition。 其中Community Server 可以直接從mysql 的官網下載。Enterprice Edition 只能從Oracle edelivery上下載,不過Edelivery 現在已經屏蔽了中國的IP,如果國內的用戶一般不能從edelivery上下載,需要FQ出去才能下載。

?

1.1 官方文檔上有關MySQL安裝文件類型說明:

?????? http://dev.mysql.com/doc/refman/5.5/en/index.html

?

Linux supports anumber of different solutions for installing MySQL. The recommended method isto use one of the distributions from Oracle. If you choose this method, thereare three options available:

(1)Installingfrom a generic binary package in?.tar.gz?format. See?Section?2.2,“Installing MySQL from Generic Binaries on Unix/Linux”?for moreinformation.

(2)Extractingand compiling MySQL from a source distribution. For detailed instructions,see?Section?2.9, “InstallingMySQL from Source”.

(3)Installingusing a pre-compiled RPM package. For more information on using the RPMsolution, see?Section?2.5.1,“Installing MySQL from RPM Packages on Linux”.

?????? --這里講了3種方式來安裝MySQL數據庫,我這里用最簡單的RPM 包來安裝。

?

As analternative, you can use the native package manager within your Linuxdistribution to automatically download and install MySQL for you. Nativepackage installations can take of the download and dependencies required to runMySQL, but the MySQL version will often be some way behind the currentlyavailable release. You will also normally be unable to install developmentalreleases, as these are not usually made available in the native repository. Formore information on using the native package installers, see?Section?2.5.2,“Installing MySQL on Linux using Native Package Manager”.

?

Note

For many Linux installations,you will want to set up MySQL to be started automatically when your machinestarts. Many of the native package installations perform this operation foryou, but for source, binary and RPM solutions you may need to set this upseparately. The required script,?mysql.server,can be found in the?support-filesdirectory under the MySQL installationdirectory or in a MySQL source tree. You can install itas/etc/init.d/mysql?for automatic MySQL startup and shutdown. See?Section?2.10.1.2,“Starting and Stopping MySQL Automatically”.

?????? --這里要注意一個問題,就是設置MySQL的自啟動。 如果使用native package來安裝,會自動設置為自啟動,如果使用其他的方式,如source,binary和RPM,就需要單獨的來設置自啟動。

?

1.2 下載安裝包

?????? 我這里下載Community Server 版的,Enterprise Edition版的請到Oracle E-Delivery上下載。Enterprise Edition 有30天的試用期。


? Community Server下載地址:http://www.mysql.com/downloads/mysql/

?

?

這里要注意的,MySQL的Tar 包還是比較大,要比RPM包大3倍左右。

?

MySQL 的RPM 包有如下幾個:

?


看一下每個rpm 包具體的描述:

(1)MySQL-server-VERSION.glibc23.i386.rpm

The MySQLserver. You need this unless you only want to connect to a MySQL server runningon another machine.

?

(2)MySQL-client-VERSION.glibc23.i386.rpm

The standardMySQL client programs. You probably always want to install this package.

?

(3)MySQL-devel-VERSION.glibc23.i386.rpm

The librariesand include files that are needed if you want to compile other MySQL clients,such as the Perl modules.

?

(4)MySQL-debuginfo-VERSION.glibc23.i386.rpm

This packagecontains debugging information.?debuginfo?RPMs are never needed touse MySQL software; this is true both for the server and for client programs.However, they contain additional information that might be needed by a debuggerto analyze a crash.

?

(5)MySQL-shared-VERSION.glibc23.i386.rpm

This packagecontains the shared libraries (libmysqlclient.so*) that certain languages andapplications need to dynamically load and use MySQL. It containssingle-threaded and thread-safe libraries. Prior toMySQL 5.5.6, if you install this package, do not installthe?MySQL-shared-compat?package.

?

(6)MySQL-shared-compat-VERSION.glibc23.i386.rpm

This packageincludes the shared libraries for MySQL 3.23, 4.0, and so on. It containssingle-threaded and thread-safe libraries. Install this package if you have applicationsinstalled that are dynamically linked against older versions of MySQL but youwant to upgrade to the current version without breaking the librarydependencies. Before MySQL 5.5.6,?MySQL-shared-compat?also includesthe libraries for the current release, so if you install it, you should notalso install?MySQL-shared. As of 5.5.6,?MySQL-shared-compat?doesnot include the current library version, so there is no conflict.

?

(7)MySQL-embedded-VERSION.glibc23.i386.rpm

The embeddedMySQL server library.

?

(8)MySQL-test-VERSION.glibc23.i386.rpm

This packageincludes the MySQL test suite.

?

(9)MySQL-VERSION.src.rpm

This containsthe source code for all of the previous packages. It can also be used torebuild the RPMs on other architectures (for example, Alpha or SPARC).

?

二. 安裝MySQL

2.1 安裝說明

(1)MySQL的安裝包有很多個,作用也不同,在大多數情況下,只需要安裝MySQL-server 和 MySQL-client,其他的包根據需要來安裝。

?

(2)The server RPM places data underthe?/var/lib/mysql?directory. The RPM also creates a login accountfor a user named?mysql?(if one does not exist) to use for running theMySQL server, and creates the appropriate entries in?/etc/init.d/?tostart the server automatically at boot time. (This means that if you haveperformed a previous installation and have made changes to its startup script,you may want to make a copy of the script so that you do not lose it when youinstall a newer RPM.)?

?

(3)During RPM installation, a usernamed?mysql?and a group named?mysql?are created on thesystem. This is done using the?useradd,?groupadd,and?usermod?commands. Those commands require appropriateadministrative privileges, which is required for locally managed users andgroups (as listed in the?/etc/passwd?and?/etc/groupfiles) by theRPM installation process being run by?root.

?????? --在MySQL 安裝時,會創建mysql 用戶和mysql組。

?

(4)MySQL 的相關目錄說明

/usr/bin : Client programs and scripts?? ?-- mysqladmin mysqldump等命令

/usr/sbin:  The?mysqld?server

/var/lib/mysql: Log files, databases ?--這個目錄就是數據庫的目錄

/usr/share/info: Manual in Info format

/usr/share/man: Unix manual pages

/usr/include/mysql: Include (header) files

/usr/lib/mysql: Libraries

/usr/share/mysql : Miscellaneous support files,including error messages, character set files, sample configuration files, SQLfor database installation

?????????? ??? --mysql.server命令及配置文件

/usr/share/sql-bench: Benchmarks

/etc/rc.d/init.d/: 啟動腳本文件mysql的目錄

?

2.2 安裝

--安裝Server端:

[root@rac2 software]# ls

MySQL-client-5.5.15-1.rhel5.x86_64.rpm

MySQL-devel-5.5.15-1.rhel5.x86_64.rpm

MySQL-embedded-5.5.15-1.rhel5.x86_64.rpm

MySQL-server-5.5.15-1.rhel5.x86_64.rpm

MySQL-shared-5.5.15-1.rhel5.x86_64.rpm

MySQL-shared-compat-5.5.15-1.rhel5.x86_64.rpm

MySQL-test-5.5.15-1.rhel5.x86_64.rpm

?

[root@rac2 software]# rpm -ivh MySQL-server-5.5.15-1.rhel5.x86_64.rpm

Preparing...???????????????########################################### [100%]

??1:MySQL-server??????????########################################### [100%]

?

PLEASE REMEMBER TO SET A PASSWORD FOR THEMySQL root USER !

To do so, start the server, then issue thefollowing commands:

?

/usr/bin/mysqladmin -u root password'new-password'

/usr/bin/mysqladmin -u root -h rac2password 'new-password'

?

Alternatively you can run:

/usr/bin/mysql_secure_installation

?

which will also give you the option ofremoving the test

databases and anonymous user created bydefault.? This is

strongly recommended for productionservers.

?

See the manual for more instructions.

?

Please report any problems with the /usr/bin/mysqlbugscript!

?

[root@rac2 software]#

?

--- 安裝客戶端

[root@rac2 software]# rpm -ivh MySQL-client-5.5.15-1.rhel5.x86_64.rpm

Preparing...???????????????########################################### [100%]

??1:MySQL-client?????????? ###########################################[100%]

?

2.3 其他操作

2.3.1 查看在時創建的mysql用戶和mysql group:

[root@rac2 bin]# cat /etc/passwd|grep mysql

mysql:x:103:106:MySQLserver:/var/lib/mysql:/bin/bash

[root@rac2 bin]# cat /etc/group | grepmysql

mysql:x:106:

?

2.3.2 修改密碼

--連接MySQL 報錯:

[root@rac2 software]# mysql

ERROR 2002 (HY000): Can't connect to localMySQL server through socket '/var/lib/mysql/mysql.sock' (2)

?

--啟動MySQL 后,在連正常:

[root@rac2 ~]# /etc/init.d/mysql start

Starting MySQL...???????????????????????? ?????????????????[? OK? ]

[root@rac2 init.d]# mysql

Welcome to the MySQL monitor.? Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.15 MySQL CommunityServer (GPL)

?

Copyright (c) 2000, 2010, Oracle and/or itsaffiliates. All rights reserved.

?

Oracle is a registered trademark of OracleCorporation and/or its

affiliates. Other names may be trademarksof their respective

owners.

?

Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.

?

mysql>

--注意這里,因為MySQL默認沒有密碼,所以這里我們沒有輸入密碼就直接連上了。

?

--修改密碼,這個是安裝Server 中提示的:

[root@rac2 ~]# /usr/bin/mysqladmin -u root password root

[root@rac2 ~]# mysql

ERROR 1045 (28000): Access denied for user'root'@'localhost' (using password: NO)

--修改密碼之后,就提示要使用密碼了。

?

[root@rac2 ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.? Commands end with ; or \g.

Your MySQL connection id is 5

Server version: 5.5.15 MySQL CommunityServer (GPL)

?

Copyright (c) 2000, 2010, Oracle and/or itsaffiliates. All rights reserved.

?

Oracle is a registered trademark of OracleCorporation and/or its affiliates. Other names may be trademarks of theirrespective owners.

?

Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.

?

mysql>

--輸入密碼后成功連接。

?

?

2.3.3 查看MySQL端口 3306, 這個是默認端口:

[root@rac2 ~]# netstat -nat|grep 3306

tcp???????0????? 0 192.168.3.100:32842???????? 192.168.3.100:3306????????? TIME_WAIT??

tcp???????0????? 0 :::3306???????????????????? :::*??????????????????????? LISTEN?????

?

2.3.4 設置開機自啟動

--查看MySQL 開機自啟動設置:

[root@rac2 ~]# chkconfig --list |grep mysql

mysql?????????? 0:off?? 1:off??2:on??? 3:on??? 4:on???5:on??? 6:off

這里的數字分別代表Linux啟動的不同模式,3是命令行,5是窗口。

?

--關閉開機自啟動

[root@rac2 ~]# chkconfig mysql off

[root@rac2 ~]# chkconfig --list |grep mysql

mysql??????????0:off?? 1:off??2:off?? 3:off?? 4:off??5:off?? 6:off

?

--啟用開機自啟動:

[root@rac2 ~]# chkconfig mysql on

[root@rac2 ~]# chkconfig --list |grep mysql

mysql?????????? 0:off?? 1:off??2:on??? 3:on??? 4:on???5:on??? 6:off

[root@rac2 ~]#

?

--將Mysql 從chkconfig服務里刪除:

[root@rac2 ~]# chkconfig --del mysql

[root@rac2 ~]# chkconfig --list |grep mysql

?

--將Mysql 添加到chkconfig里:

[root@rac2 ~]# chkconfig --add mysql??????

[root@rac2 ~]# chkconfig --list |grep mysql

mysql?????????? 0:off?? 1:off??2:on??? 3:on??? 4:on???5:on??? 6:off

?

2.4 數據庫操作

[root@rac2 ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.? Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.5.15 MySQL CommunityServer (GPL)

?

Copyright (c) 2000, 2010, Oracle and/or itsaffiliates. All rights reserved.

?

Oracle is a registered trademark of OracleCorporation and/or its

affiliates. Other names may be trademarksof their respective

owners.

?

Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.

?

--查看已經存在的數據庫,這幾個是安裝時自動創建的

mysql> show databases;

+--------------------+

| Database?????????? |

+--------------------+

| information_schema |

| mysql????????????? |

| performance_schema |

| test?????????????? |

+--------------------+

4 rows in set (0.00 sec)

?

--使用mysql 數據庫

mysql> use mysql

Reading table information for completion oftable and column names

You can turn off this feature to get aquicker startup with -A

?

Database changed

?

--查看mysql 數據庫下面的表

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??????????????? |

| proxies_priv????????????? |

| servers?????????????????? |

| slow_log????????????????? |

| tables_priv?????????????? |

| time_zone???????????????? |

| time_zone_leap_second???? |

| time_zone_name??????????? |

| time_zone_transition????? |

| time_zone_transition_type |

| user????????? ????????????|

+---------------------------+

24 rows in set (0.01 sec)

?

--創建數據庫Dave

mysql> create database dave;

Query OK, 1 row affected (0.01 sec)

?

--在dave 數據庫下面創建dave表:

mysql> use dave;

Database changed

mysql> create table dave(id int,namechar(20));

Query OK, 0 rows affected (0.01 sec)

?

--查看dave 表結構:

mysql> desc dave;

+-------+----------+------+-----+---------+-------+

| Field | Type???? | Null | Key | Default | Extra |

+-------+----------+------+-----+---------+-------+

| id???| int(11)? | YES? |?? ??| NULL???|?????? |

| name?| char(20) | YES? |???? | NULL???|?????? |

+-------+----------+------+-----+---------+-------+

2 rows in set (0.00 sec)

?

--向dave 表里插入2條記錄:

mysql> insert into davevalues(1,'dave');

Query OK, 1 row affected (0.00 sec)

?

mysql> insert into davevalues(2,'anqing');

Query OK, 1 row affected (0.01 sec)

?

mysql> select * from dave;

+------+--------+

| id??| name?? |

+------+--------+

|???1 | dave?? |

|???2 | anqing |

+------+--------+

2 rows in set (0.00 sec)

?

--update 表:

mysql> update dave set name='david dai'where id=1;

Query OK, 1 row affected (0.01 sec)

Rows matched: 1? Changed: 1?Warnings: 0

?

mysql> select * from dave;

+------+-----------+

| id??| name????? |

+------+-----------+

|???1 | david dai |

|???2 | anqing??? |

+------+-----------+

2 rows in set (0.00 sec)

?

--drop 表:

mysql> drop table dave;

Query OK, 0 rows affected (0.01 sec)

?

--drop 數據庫:

mysql> drop database dave;

Query OK, 0 rows affected (0.00 sec)

?

mysql> show databases;

+--------------------+

| Database??? ???????|

+--------------------+

| information_schema |

| mysql????????????? |

| performance_schema |

| test?????????????? |

+--------------------+

4 rows in set (0.01 sec)



至此,操作結束。?


?

?

?

?

-------------------------------------------------------------------------------------------------------

版權所有,文章允許轉載,但必須以鏈接方式注明源地址,否則追究法律責任!

Blog:???? http://blog.csdn.net/tianlesoftware

Weibo: http://weibo.com/tianlesoftware

Email: ? tianlesoftware@gmail.com

Skype: tianlesoftware

?

-------加群需要在備注說明Oracle表空間和數據文件的關系,否則拒絕申請----

DBA1 群:62697716(滿);?? DBA2 群:62697977(滿)??DBA3 群:62697850(滿)??

DBA 超級群:63306533(滿);? DBA4 群:83829929(滿) DBA5群: 142216823(滿)?

DBA6 群:158654907(滿)?? DBA7 群:69087192(滿)??DBA8 群:172855474

DBA 超級群2:151508914? DBA9群:102954821???? 聊天 群:40132017(滿)

轉載于:https://www.cnblogs.com/springside-example/archive/2011/11/22/2529609.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/377970.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/377970.shtml
英文地址,請注明出處:http://en.pswp.cn/news/377970.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

開始python之旅

接觸python緣于工作所需,曾經接觸過C、C等語言,對于編程語言在學習上大體是一個套路,當然套路因人而異,適合就好。接下來,我將不斷分享python的知識和學習技巧,共同學習。 起源 初識一門語言善于先了解語言…

LeetCode 112. 路徑總和 、113. 路徑總和 II 思考分析

目錄112. 路徑總和題目遞歸解遞歸解,其他人的解法迭代解,其他人的解法113. 路徑總和 II題目遞歸解遞歸解,參考別人的思路112. 路徑總和 題目 給定一個二叉樹和一個目標和,判斷該樹中是否存在根節點到葉子節點的路徑,…

kotlin 查找id_Kotlin程序查找矩陣的轉置

kotlin 查找idA transpose of a matrix is simply a flipped version of the original matrix. We can transpose a matrix by switching its rows with its columns 矩陣的轉置只是原始矩陣的翻轉形式。 我們可以通過切換矩陣的行和列來轉置矩陣 Given a matrix, we have to…

[mongodb翻譯]分片和故障轉移

一個配置恰當的mongodb 分片集群不會有單點失效。 本章節描述了集群服務器中可能出現的故障,及相應的對策。 1. 某個mongos路由進程故障 每一個mongos會運行每一臺應用服務器上面,該應用服務器只能通過這個mongos進程和集群進行通信。mongos進程不是…

看張子陽的書真是收獲很多,也醒悟了很多(一)

摘錄: 這是有一次開會時,我的老總跟我們說了這樣一個事例:通常來說,醫生是很高尚的職業(暫不考慮國內醫生的負面新聞),尤其是牙科醫生, 他們有著體面的工作并且收入不菲。但是&#…

【C++ grammar】抽象、封裝與this指針

目錄1、Abstraction and Encapsulation(抽象與封裝)1. Data Field Encapsulation (數據域封裝)2. Accessor and Mutator (訪問器與更改器)2.1. To read/write private data, we need get/set function (為讀寫私有數據,需要get/set函數)2.2. …

java創建臨時文件_用Java創建一個臨時文件

java創建臨時文件The task is to create a temporary file in Java. 任務是用Java創建一個臨時文件。 Creating a temporary file 創建一個臨時文件 To create a temporary file in java – we use createTempFile() method of "File" class. The createTempFile()…

十九、圖像的形態學操作

一、圖像形態學 圖像形態學是圖像處理學科的一個單獨分支學科 主要針對的是灰度圖和二值圖像 是由數學的集合論以及數學中的拓撲幾何原理發展而來 二、膨脹操作(dilate) 33的卷積核 以33為卷積核從左往右(從上往下)開始運行,若這卷積核…

X名稱空間(WPF)

筆記簡述 閑話x名稱空間簡要x名稱空間的Attributex名稱空間的標簽擴展x名稱空間的XAML指令元素閑話 本筆記參考與《深入淺出WPF》、MSDN、Some Blog… MSDN的飛機票點這里。 x名稱空間簡要 在VS中新建個WpfApplication都會自動生成xmlns:x"http://schemas.microsoft.com/w…

基于Bresenham和DDA算法畫線段

直線:ykxb 為了將他在顯示屏上顯示出來,我們需要為相應的點賦值,那么考慮到計算機的乘法執行效率,我們肯定不會選擇用Ykxb這個表達式求值,然后進行畫線段。 我們應當是將它轉化為加法運算。 下面提供兩種常見的算法&am…

leetcode 106. 從中序與后序遍歷序列構造二叉樹 105. 從前序與中序遍歷序列構造二叉樹思考分析

目錄1、106題目2、參考思路:遞歸切割數組3、105題目4、同樣思路的代碼1、106題目 2、參考思路:遞歸切割數組 代碼參考:公眾號:代碼隨想錄 后序數組中序數組 以 后序數組(左右中)的最后一個元素作為切割點,先切中序數組…

按頻率對元素進行排序

Prerequisite: 先決條件: Hashing data structure 散列數據結構 How to write user-defined comparator for priority queue STL in C? 如何在C 中為優先級隊列STL編寫用戶定義的比較器? How to sort a map based on values instead of value? 如何根…

二十、分水嶺算法

一、基本原理 分水嶺算法主要是基于距離變換(distance transform),找到mark一些種子點,從這些種子點出發根據像素梯度變化進行尋找邊緣并標記 分水嶺:可以簡單的理解成一座山,然后來洪水了,水開…

細數WOW里暴雪的“親兒子”們

. 不知何時,魔獸世界的詞匯中忽然出現了一個新玩意:親兒子。雖說這個稱呼現在大多是拿來調侃法爺的,但江山代有兒子出,各領風騷一兩天,今天風光無限的法爺們也經歷過被其他職業壓得抬不起頭的小媳婦生涯。那么今天…

Linux下串口ttyS2,ttyS3不能用的問題解決辦法

PC104,Xlinux下,突然發現串口3,4不能用。。。 以為是硬件的問題,換成wince后,3,4工作正常,排除電路問題 在linux下查看dmesg: serial8250: ttyS0 at I/O 0x3f8 (irq 4) is a 16550Aserial8250: ttyS1 at I/O 0x2f8 (i…

安卓log.e函數打印示例_log1p()函數以及C ++中的示例

安卓log.e函數打印示例C log1p()函數 (C log1p() function) log1p() function is a library function of cmath header, it is used to get the natural logarithm (the base-e logarithm) of the one plus given value. It accepts a value (float, double, or long double) …

【C++grammar】C++類數據成員的初始化

目錄1、類成員的就地初始化example2、構造函數初始化3、默認構造函數:Default Constructor4、舉例5、成員的初始化方法的優先級1、類成員的就地初始化example class S { int m 7; // ok, copy-initializes m int n(7); // 錯誤:不允許用小括號初始化…

二十一、人臉檢測

一、識別圖像中的人臉 haarcascade_frontalface_alt_tree.xml lbpcascade_frontalcatface.xml GitHub上有Haar級聯檢測器源代碼可自行下載,lbp級聯檢測器也一樣有源碼可自行下載 也一樣 import cv2 as cv import numpy as npdef face_detect(image):gray cv.cvtC…

aspx特殊符號說明

http://www.cnblogs.com/GnagWang/archive/2010/07/14/1777130.html轉載于:https://www.cnblogs.com/mingyongcheng/archive/2011/11/24/2261253.html

javascript運算符_JavaScript中的按位運算符

javascript運算符JavaScript按位運算符 (JavaScript Bitwise Operators) A lot of times you come across some strange operators where youre knocking your head to understand what is going on in the code. Almost all the programming languages have bitwise operators…