中文字幕第五页-中文字幕第页-中文字幕韩国-中文字幕最新-国产尤物二区三区在线观看-国产尤物福利视频一区二区

Linux中怎么安裝MySQL5.5

這篇文章將為大家詳細講解有關Linux中怎么安裝MySQL5.5,文章內容質量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關知識有一定的了解。

創(chuàng)新互聯建站為客戶提供專業(yè)的網站設計、成都網站建設、程序、域名、空間一條龍服務,提供基于WEB的系統(tǒng)開發(fā). 服務項目涵蓋了網頁設計、網站程序開發(fā)、WEB系統(tǒng)開發(fā)、微信二次開發(fā)、手機網站制作等網站方面業(yè)務。

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

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  for moreinformation.

(2)Extractingand compiling MySQL from a source distribution. For detailed instructions,see .

(3)Installingusing a pre-compiled RPM package. For more information on using the RPMsolution, see .

       --這里講了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 .

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, ,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 .

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

1.2 下載安裝包

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

   Community Server下載地址:

這里要注意的,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 安裝時,會創(chuàng)建mysql 用戶和mysql組。

(4)MySQL 的相關目錄說明

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

/usr/sbin:  The  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 查看在時創(chuàng)建的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

這里的數字分別代表啟動的不同模式,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 ~]#  -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,  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.

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

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)

--創(chuàng)建數據庫Dave

mysql> create database dave;

Query OK, 1 row affected (0.01 sec)

--在dave 數據庫下面創(chuàng)建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)

關于Linux中怎么安裝MySQL5.5就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

當前文章:Linux中怎么安裝MySQL5.5
網站鏈接:http://m.2m8n56k.cn/article22/pgcgcc.html

成都網站建設公司_創(chuàng)新互聯,為您提供網站排名網站制作建站公司外貿網站建設網站改版商城網站

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:[email protected]。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯

h5響應式網站建設
主站蜘蛛池模板: 欧美日韩综合高清一区二区 | 一区二区三区不卡在线观看 | 国产欧美日韩精品第三区 | 亚洲精品国产精品一区二区 | 久久久久香蕉视频 | 黄频漫画| 一色屋成人免费精品网 | 亚洲天堂成人在线观看 | 精品国产看高清国产毛片 | 一本本久综合久久爱 | 国产精品视频一区二区三区 | 亚洲欧洲一区二区三区久久 | 亚洲成在 | 一级片欧美 | 色偷偷亚洲女人天堂观看欧 | 杨幂精品国产专区91在线 | 国产中文字幕在线播放 | 久久久精品久久视频只有精品 | 三级三级三级全黄 | 国产一区二区三区不卡免费观看 | 日本在线毛片视频免费看 | 看一级毛片一区二区三区免费 | 国产美女一区二区三区 | 国产高清在线精品一区在线 | 男人的天堂久久爱 | 91精品欧美综合在线观看 | 中文字幕乱码中文乱码综合 | 思思91精品国产综合在线 | 久久国产中文字幕 | 亚洲成人免费在线观看 | 精品久久久久久综合网 | 国产综合成人久久大片91 | 三级网站在线免费观看 | 成人精品国产亚洲 | 免费视频男女 | a级午夜毛片免费一区二区 a级性生活视频 | 一区二区三区欧美日韩国产 | 91亚洲精品久久91 | 一本一本久久a久久精品综合麻豆 | 国产欧美日韩在线不卡第一页 | 51久久夜色精品国产 |