欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

CentOS6.4系統(tǒng)中Mysql數(shù)據(jù)庫卸載、安裝與配置教程[圖文]

  發(fā)布時間:2013-08-05 10:25:57   作者:佚名   我要評論
就像Windows server 2003,2008中一般安裝的是Sql Server 數(shù)據(jù)庫,在linux系統(tǒng)中一般安裝的是mysql數(shù)據(jù)庫,而且Mysql數(shù)據(jù)庫的第一個版本就是發(fā)行在Linux系統(tǒng)上的

一、mysql簡介

MySQL是一個關(guān)系型數(shù)據(jù)庫管理系統(tǒng),由瑞典MySQL AB公司開發(fā),目前屬于Oracle公司。MySQL是一種關(guān)聯(lián)數(shù)據(jù)庫管理系統(tǒng),關(guān)聯(lián)數(shù)據(jù)庫將數(shù)據(jù)保存在不同的表中,而不是將所有數(shù)據(jù)放在一個大倉庫內(nèi),這樣就增加了速度并提高了靈活性。MySQL的SQL語言是用于訪問數(shù)據(jù)庫的最常用標(biāo)準(zhǔn)化語言。MySQL軟件采用了雙授權(quán)政策(本詞條“授權(quán)政策”),它分為社區(qū)版和商業(yè)版,由于其體積小、速度快、總體擁有成本低,尤其是開放源碼這一特點,一般中小型網(wǎng)站的開發(fā)都選擇MySQL作為網(wǎng)站數(shù)據(jù)庫。由于其社區(qū)版的性能卓越,搭配PHP和Apache可組成良好的開發(fā)環(huán)境。
在Linux上安裝mysql數(shù)據(jù)庫,我們可以去其官網(wǎng)上下載mysql數(shù)據(jù)庫的rpm包,http://dev.mysql.com/downloads/mysql/5.6.html#downloads,大家可以根據(jù)自己的操作系統(tǒng)去下載對應(yīng)的數(shù)據(jù)庫文件,目前最新的版本是5.6.10了。

在這里我是通過yum來進(jìn)行mysql數(shù)據(jù)庫的安裝的,通過這種方式進(jìn)行安裝,可以將跟mysql相關(guān)的一些服務(wù)、jar包都給我們安裝好,所以省去了很多不必要的麻煩?。。?/p>

二、卸載掉原有mysql

因為mysql數(shù)據(jù)庫在Linux上實在是太流行了,所以目前下載的主流Linux系統(tǒng)版本基本上都集成了mysql數(shù)據(jù)庫在里面,我們可以通過如下命令來查看我們的操作系統(tǒng)上是否已經(jīng)安裝了mysql數(shù)據(jù)庫
[root@xiaoluo ~]# rpm -qa | grep mysql  // 這個命令就會查看該操作系統(tǒng)上是否已經(jīng)安裝了mysql數(shù)據(jù)庫
有的話,我們就通過 rpm -e 命令 或者 rpm -e --nodeps 命令來卸載掉

[root@xiaoluo ~]# rpm -e mysql  // 普通刪除模式
[root@xiaoluo ~]# rpm -e --nodeps mysql  // 強(qiáng)力刪除模式,如果使用上面命令刪除時,提示有依賴的其它文件,則用該命令可以對其進(jìn)行強(qiáng)力刪除

在刪除完以后我們可以通過 rpm -qa | grep mysql 命令來查看mysql是否已經(jīng)卸載成功??!

三、通過yum來進(jìn)行mysql的安裝

我是通過yum的方式來進(jìn)行mysql的數(shù)據(jù)庫安裝,首先我們可以輸入 yum list | grep mysql 命令來查看yum上提供的mysql數(shù)據(jù)庫可下載的版本:

[root@xiaoluo ~]# yum list | grep mysql

就可以得到y(tǒng)um服務(wù)器上mysql數(shù)據(jù)庫的可下載版本信息:



然后我們可以通過輸入 yum install -y mysql-server mysql mysql-devel 命令將mysql mysql-server mysql-devel都安裝好(注意:安裝mysql時我們并不是安裝了mysql客戶端就相當(dāng)于安裝好了mysql數(shù)據(jù)庫了,我們還需要安裝mysql-server服務(wù)端才行)

[root@xiaoluo ~]# yum install -y mysql-server mysql mysql-deve

在等待了一番時間后,yum會幫我們選擇好安裝mysql數(shù)據(jù)庫所需要的軟件以及其它附屬的一些軟件

我們發(fā)現(xiàn),通過yum方式安裝mysql數(shù)據(jù)庫省去了很多沒必要的麻煩,當(dāng)出現(xiàn)下面的結(jié)果時,就代表mysql數(shù)據(jù)庫安裝成功了


此時我們可以通過如下命令,查看剛安裝好的mysql-server的版本

[root@xiaoluo ~]# rpm -qi mysql-server
我們安裝的mysql-server并不是最新版本,如果你想嘗試最新版本,那就去mysql官網(wǎng)下載rpm包安裝就行了,至此我們的mysql數(shù)據(jù)庫已經(jīng)安裝完成了。

四、mysql數(shù)據(jù)庫的初始化及相關(guān)配置

我們在安裝完mysql數(shù)據(jù)庫以后,會發(fā)現(xiàn)會多出一個mysqld的服務(wù),這個就是咱們的數(shù)據(jù)庫服務(wù),我們通過輸入 service mysqld start 命令就可以啟動我們的mysql服務(wù)。

注意:如果我們是第一次啟動mysql服務(wù),mysql服務(wù)器首先會進(jìn)行初始化的配置,如:

[root@xiaoluo ~]# service mysqld start

初始化 MySQL 數(shù)據(jù)庫: WARNING: The host 'xiaoluo' 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

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

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

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

[確定]
正在啟動 mysqld: [確定]

這時我們會看到第一次啟動mysql服務(wù)器以后會提示非常多的信息,目的就是對mysql數(shù)據(jù)庫進(jìn)行初始化操作,當(dāng)我們再次重新啟動mysql服務(wù)時,就不會提示這么多信息了,如:
[root@xiaoluo ~]# service mysqld restart
停止 mysqld: [確定]
正在啟動 mysqld: [確定]
我們在使用mysql數(shù)據(jù)庫時,都得首先啟動mysqld服務(wù),我們可以 通過 chkconfig --list | grep mysqld 命令來查看mysql服務(wù)是不是開機(jī)自動啟動,如:

[root@xiaoluo ~]# chkconfig --list | grep mysqld

mysqld 0:關(guān)閉 1:關(guān)閉 2:關(guān)閉 3:關(guān)閉 4:關(guān)閉 5:關(guān)閉 6:關(guān)閉
我們發(fā)現(xiàn)mysqld服務(wù)并沒有開機(jī)自動啟動,我們當(dāng)然可以通過 chkconfig mysqld on 命令來將其設(shè)置成開機(jī)啟動,這樣就不用每次都去手動啟動了

[root@xiaoluo ~]# chkconfig mysqld on
[root@xiaoluo ~]# chkconfig --list | grep mysql

mysqld 0:關(guān)閉 1:關(guān)閉 2:啟用 3:啟用 4:啟用 5:啟用 6:關(guān)閉
mysql數(shù)據(jù)庫安裝完以后只會有一個root管理員賬號,但是此時的root賬號還并沒有為其設(shè)置密碼,在第一次啟動mysql服務(wù)時,會進(jìn)行數(shù)據(jù)庫的一些初始化工作,在輸出的一大串信息中,我們看到有這樣一行信息 :

/usr/bin/mysqladmin -u root password 'new-password'  // 為root賬號設(shè)置密碼

所以我們可以通過 該命令來給我們的root賬號設(shè)置密碼(注意:這個root賬號是mysql的root賬號,非Linux的root賬號)

[root@xiaoluo ~]# mysqladmin -u root password 'root'  // 通過該命令給root賬號設(shè)置密碼為 root

此時我們就可以通過 mysql -u root -p 命令來登錄我們的mysql數(shù)據(jù)庫了



五、mysql數(shù)據(jù)庫的主要配置文件

1./etc/my.cnf 這是mysql的主配置文件
我們可以查看一下這個文件的一些信息
[root@xiaoluo etc]# ls my.cnf
my.cnf

[root@xiaoluo etc]# cat my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
2./ver/lib/mysql   mysql數(shù)據(jù)庫的數(shù)據(jù)庫文件存放位置
我們的mysql數(shù)據(jù)庫的數(shù)據(jù)庫文件通常是存放在了/ver/lib/mysql這個目錄下
[root@xiaoluo ~]# cd /var/lib/mysql/
[root@xiaoluo mysql]# ls -l
總用量 20488
-rw-rw----. 1 mysql mysql 10485760 4月   6 22:01 ibdata1
-rw-rw----. 1 mysql mysql  5242880 4月   6 22:01 ib_logfile0
-rw-rw----. 1 mysql mysql  5242880 4月   6 21:59 ib_logfile1
drwx------. 2 mysql mysql     4096 4月   6 21:59 mysql  // 這兩個是mysql數(shù)據(jù)庫安裝時默認(rèn)的兩個數(shù)據(jù)庫文件
srwxrwxrwx. 1 mysql mysql        0 4月   6 22:01 mysql.sock
drwx------. 2 mysql mysql     4096 4月   6 21:59 test  // 這兩個是mysql數(shù)據(jù)庫安裝時默認(rèn)的兩個數(shù)據(jù)庫文件
我們可以自己創(chuàng)建一個數(shù)據(jù)庫,來驗證一下該數(shù)據(jù)庫文件的存放位置
創(chuàng)建一個我們自己的數(shù)據(jù)庫:
mysql> create database xiaoluo;
Query OK, 1 row affected (0.00 sec)

[root@xiaoluo mysql]# ls -l
總用量 20492
-rw-rw----. 1 mysql mysql 10485760 4月   6 22:01 ibdata1
-rw-rw----. 1 mysql mysql  5242880 4月   6 22:01 ib_logfile0
-rw-rw----. 1 mysql mysql  5242880 4月   6 21:59 ib_logfile1
drwx------. 2 mysql mysql     4096 4月   6 21:59 mysql
srwxrwxrwx. 1 mysql mysql        0 4月   6 22:01 mysql.sock
drwx------. 2 mysql mysql     4096 4月   6 21:59 test
drwx------. 2 mysql mysql     4096 4月   6 22:15 xiaoluo  // 這個就是我們剛自己創(chuàng)建的xiaoluo數(shù)據(jù)庫
[root@xiaoluo mysql]# cd xiaoluo/
[root@xiaoluo xiaoluo]# ls
db.opt
3./var/log mysql數(shù)據(jù)庫的日志輸出存放位置
我們的mysql數(shù)據(jù)庫的一些日志輸出存放位置都是在/var/log這個目錄下
[root@xiaoluo xiaoluo]# cd
[root@xiaoluo ~]# cd /var/log
[root@xiaoluo log]# ls
amanda                cron           maillog-20130331   spice-vdagent.log
anaconda.ifcfg.log    cron-20130331  mcelog             spooler
anaconda.log          cups           messages           spooler-20130331
anaconda.program.log  dirsrv         messages-20130331  sssd
anaconda.storage.log  dmesg          mysqld.log         tallylog
anaconda.syslog       dmesg.old      ntpstats           tomcat6
anaconda.xlog         dracut.log     piranha            wpa_supplicant.log
anaconda.yum.log      gdm            pm-powersave.log   wtmp
audit                 httpd          ppp                Xorg.0.log
boot.log              ibacm.log      prelink            Xorg.0.log.old
btmp                  lastlog        sa                 Xorg.1.log
btmp-20130401         libvirt        samba              Xorg.2.log
cluster               luci           secure             Xorg.9.log
ConsoleKit            maillog        secure-20130331    yum.log

其中mysqld.log 這個文件就是我們存放我們跟mysql數(shù)據(jù)庫進(jìn)行操作而產(chǎn)生的一些日志信息,通過查看該日志文件,我們可以從中獲得很多信息
因為我們的mysql數(shù)據(jù)庫是可以通過網(wǎng)絡(luò)訪問的,并不是一個單機(jī)版數(shù)據(jù)庫,其中使用的協(xié)議是 tcp/ip 協(xié)議,我們都知道m(xù)ysql數(shù)據(jù)庫綁定的端口號是 3306 ,所以我們可以通過 netstat -anp 命令來查看一下,Linux系統(tǒng)是否在監(jiān)聽 3306 這個端口號:

結(jié)果如上所示,Linux系統(tǒng)監(jiān)聽的3306端口號就是我們的mysql數(shù)據(jù)庫?。。。?/p>

相關(guān)文章

最新評論