欧美日韩精品在线,国内精品久久久久久久久,一级毛片恃级毛片直播,清纯唯美亚洲综合欧美色

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

編輯Tag賺U幣
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!

推薦:mysql的binlog太大太多占用大量磁盤(pán)的解決
現(xiàn)象:網(wǎng)站訪問(wèn)越來(lái)越慢,最后無(wú)法訪問(wèn)了,經(jīng)過(guò)檢查發(fā)現(xiàn)磁盤(pán)滿(mǎn)了。仔細(xì)查詢(xún)下來(lái)確認(rèn)是由于mysql的binlog太多太大占用了空間。 分析過(guò)程及解決方案:通常出現(xiàn)這種問(wèn)題都應(yīng)該登錄服務(wù)器檢查磁盤(pán)、內(nèi)存和進(jìn)程使用的情況,通過(guò)top、df h和free m來(lái)檢查,發(fā)現(xiàn)磁盤(pán)空間滿(mǎn)了。

   就像Windows server 2003,2008中一般安裝的是Sql Server 數(shù)據(jù)庫(kù),在linux系統(tǒng)中一般安裝的是mysql數(shù)據(jù)庫(kù),而且Mysql數(shù)據(jù)庫(kù)的第一個(gè)版本就是發(fā)行在Linux系統(tǒng)上的。

  一、mysql簡(jiǎn)介

  MySQL是一個(gè)關(guān)系型數(shù)據(jù)庫(kù)管理系統(tǒng),由瑞典MySQL AB公司開(kāi)發(fā),目前屬于Oracle公司。MySQL是一種關(guān)聯(lián)數(shù)據(jù)庫(kù)管理系統(tǒng),關(guān)聯(lián)數(shù)據(jù)庫(kù)將數(shù)據(jù)保存在不同的表中,而不是將所有數(shù)據(jù)放在一個(gè)大倉(cāng)庫(kù)內(nèi),這樣就增加了速度并提高了靈活性。MySQL的SQL語(yǔ)言是用于訪問(wèn)數(shù)據(jù)庫(kù)的最常用標(biāo)準(zhǔn)化語(yǔ)言。MySQL軟件采用了雙授權(quán)政策(本詞條“授權(quán)政策”),它分為社區(qū)版和商業(yè)版,由于其體積小、速度快、總體擁有成本低,尤其是開(kāi)放源碼這一特點(diǎn),一般中小型網(wǎng)站的開(kāi)發(fā)都選擇MySQL作為網(wǎng)站數(shù)據(jù)庫(kù)。由于其社區(qū)版的性能卓越,搭配PHP和Apache可組成良好的開(kāi)發(fā)環(huán)境。

  在Linux上安裝mysql數(shù)據(jù)庫(kù),我們可以去其官網(wǎng)上下載mysql數(shù)據(jù)庫(kù)的rpm包,http://dev.mysql.com/downloads/mysql/5.6.html#downloads,大家可以根據(jù)自己的操作系統(tǒng)去下載對(duì)應(yīng)的數(shù)據(jù)庫(kù)文件,目前最新的版本是5.6.10了。

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

  二、卸載掉原有mysql

  因?yàn)閙ysql數(shù)據(jù)庫(kù)在Linux上實(shí)在是太流行了,所以目前下載的主流Linux系統(tǒng)版本基本上都集成了mysql數(shù)據(jù)庫(kù)在里面,我們可以通過(guò)如下命令來(lái)查看我們的操作系統(tǒng)上是否已經(jīng)安裝了mysql數(shù)據(jù)庫(kù)

  [root@xiaoluo ~]# rpm -qa | grep mysql  // 這個(gè)命令就會(huì)查看該操作系統(tǒng)上是否已經(jīng)安裝了mysql數(shù)據(jù)庫(kù)

  有的話,我們就通過(guò) rpm -e 命令 或者 rpm -e --nodeps 命令來(lái)卸載掉

  [root@xiaoluo ~]# rpm -e mysql  // 普通刪除模式

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

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

  三、通過(guò)yum來(lái)進(jìn)行mysql的安裝

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

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

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

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

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

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

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

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

  [root@xiaoluo ~]# rpm -qi mysql-server

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

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

  我們?cè)诎惭b完mysql數(shù)據(jù)庫(kù)以后,會(huì)發(fā)現(xiàn)會(huì)多出一個(gè)mysqld的服務(wù),這個(gè)就是咱們的數(shù)據(jù)庫(kù)服務(wù),我們通過(guò)輸入 service mysqld start 命令就可以啟動(dòng)我們的mysql服務(wù)。

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

  [root@xiaoluo ~]# service mysqld start

  初始化 MySQL 數(shù)據(jù)庫(kù): 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!

  [確定]

  正在啟動(dòng) mysqld: [確定]

  這時(shí)我們會(huì)看到第一次啟動(dòng)mysql服務(wù)器以后會(huì)提示非常多的信息,目的就是對(duì)mysql數(shù)據(jù)庫(kù)進(jìn)行初始化操作,當(dāng)我們?cè)俅沃匦聠?dòng)mysql服務(wù)時(shí),就不會(huì)提示這么多信息了,如:

  [root@xiaoluo ~]# service mysqld restart

  停止 mysqld: [確定]

  正在啟動(dòng) mysqld: [確定]

  我們?cè)谑褂胢ysql數(shù)據(jù)庫(kù)時(shí),都得首先啟動(dòng)mysqld服務(wù),我們可以 通過(guò) chkconfig --list | grep mysqld 命令來(lái)查看mysql服務(wù)是不是開(kāi)機(jī)自動(dòng)啟動(dòng),如:

  [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ù)并沒(méi)有開(kāi)機(jī)自動(dòng)啟動(dòng),我們當(dāng)然可以通過(guò) chkconfig mysqld on 命令來(lái)將其設(shè)置成開(kāi)機(jī)啟動(dòng),這樣就不用每次都去手動(dòng)啟動(dòng)了

  [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ù)庫(kù)安裝完以后只會(huì)有一個(gè)root管理員賬號(hào),但是此時(shí)的root賬號(hào)還并沒(méi)有為其設(shè)置密碼,在第一次啟動(dòng)mysql服務(wù)時(shí),會(huì)進(jìn)行數(shù)據(jù)庫(kù)的一些初始化工作,在輸出的一大串信息中,我們看到有這樣一行信息 :

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

  所以我們可以通過(guò) 該命令來(lái)給我們的root賬號(hào)設(shè)置密碼(注意:這個(gè)root賬號(hào)是mysql的root賬號(hào),非Linux的root賬號(hào))

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

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

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

  1./etc/my.cnf 這是mysql的主配置文件

  我們可以查看一下這個(gè)文件的一些信息

  [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ù)庫(kù)的數(shù)據(jù)庫(kù)文件存放位置

  我們的mysql數(shù)據(jù)庫(kù)的數(shù)據(jù)庫(kù)文件通常是存放在了/ver/lib/mysql這個(gè)目錄下

  [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  // 這兩個(gè)是mysql數(shù)據(jù)庫(kù)安裝時(shí)默認(rèn)的兩個(gè)數(shù)據(jù)庫(kù)文件

  srwxrwxrwx. 1 mysql mysql 0 4月 6 22:01 mysql.sock

  drwx------. 2 mysql mysql 4096 4月 6 21:59 test  // 這兩個(gè)是mysql數(shù)據(jù)庫(kù)安裝時(shí)默認(rèn)的兩個(gè)數(shù)據(jù)庫(kù)文件

  我們可以自己創(chuàng)建一個(gè)數(shù)據(jù)庫(kù),來(lái)驗(yàn)證一下該數(shù)據(jù)庫(kù)文件的存放位置

  創(chuàng)建一個(gè)我們自己的數(shù)據(jù)庫(kù):

  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  // 這個(gè)就是我們剛自己創(chuàng)建的xiaoluo數(shù)據(jù)庫(kù)

  [root@xiaoluo mysql]# cd xiaoluo/

  [root@xiaoluo xiaoluo]# ls

  db.opt

  3./var/log mysql數(shù)據(jù)庫(kù)的日志輸出存放位置

  我們的mysql數(shù)據(jù)庫(kù)的一些日志輸出存放位置都是在/var/log這個(gè)目錄下

  [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 這個(gè)文件就是我們存放我們跟mysql數(shù)據(jù)庫(kù)進(jìn)行操作而產(chǎn)生的一些日志信息,通過(guò)查看該日志文件,我們可以從中獲得很多信息

分享:SQL Server Management Studio 沒(méi)有出來(lái)
一種情況,在安裝 sqlServer2005 時(shí) 居然出現(xiàn)兩個(gè)警告: 1 Com+ 目錄要求 2 Edition change check 郁悶!網(wǎng)上說(shuō)出現(xiàn)兩個(gè)警告,是肯定裝不成功的!我抱著僥幸的態(tài)度試了下,成功了。 安裝成功后,正準(zhǔn)備 僅工具、聯(lián)機(jī)叢書(shū)和示例(T) 但是安裝不了,他提示我工作站組件安裝

共2頁(yè)上一頁(yè)12下一頁(yè)
來(lái)源:模板無(wú)憂//所屬分類(lèi):MySQL教程/更新時(shí)間:2013-04-17
相關(guān)MySQL教程