CentOS 6.5下mysql的安裝與配置

來源:互聯網
上載者:User

標籤:

一、通過yum自動安裝mysql

yum install mysql-server my-client

二、初始化及相關配置

安裝完mysql資料庫以後,會發現會多出一個mysqld的服務,通過輸入 service mysqld start 命令就可以啟動mysql服務。

第一次啟動會進行初始化配置,如下:

[[email protected] ~]# service mysqld start

初始化 MySQL 資料庫: 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,可以

 [[email protected] ~]#service mysqld restart

設定開機自啟動,命令為

[[email protected] ~]#chkconfig mysqld on

為root使用者佈建密碼,這裡的root是指mysql的root使用者,不是Linux系統的root使用者,命令為

[[email protected] ~]#mysqladmin -u root password ‘root‘ //通過命令給root帳號設定密碼為root

然後就可以通過mysql -u root -p命令來登入mysql資料庫了,然後輸入密碼登陸即可。

 

 三、mysql資料的主要設定檔
  • /etc/my.cnf 這是mysql的主設定檔,可以查看一下這個檔案的一些資訊

  • /var/lib/mysql mysql資料庫的資料庫檔案存放位置,例如我在mysql中建立了yhb資料庫,這裡就會多了一個yhb檔案

  • /var/log mysql資料庫的日誌輸出存放位置,mysql資料庫的一些日誌輸出存放位置都是在/var/log這個目錄下,其中mysqld.log這個檔案就是存放操作mysql而產生的一些日誌資訊。
  • mysql資料庫是可以通過網路訪問的,並不是一個單機版資料庫,其中使用的協議是tcp/ip協議,mysql資料庫綁定的連接埠號碼是3306,所以我們可以通過netstat -anp | grep 3306命令來查看一下。

 

CentOS 6.5下mysql的安裝與配置

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.