天天看點

centos 6.5 搭建 MySQL 服務

MySQL是一個關系型資料庫管理系統,由瑞典MySQL AB 公司開發,目前屬于 Oracle 旗下産品。MySQL 是最流行的關系型資料庫管理系統之一,在 WEB 應用方面,MySQL是最好的 RDBMS (Relational Database Management System,關系資料庫管理系統) 應用軟體。

1.檢查是否安裝mysql服務

rpm -qa | grep mysql
           

已經安裝好的會顯示

mysql-5.1.61-4.el6.i686
mysql-libs-5.1.61-4.el6.i686
mysql-server-5.1.61-4.el6.i686
php-mysql-5.3.3-3.el6_2.8.i686
           

2.yum線上安裝與rpm本地安裝,mysql服務 

yum 線上安裝mysql

yum install mysql-server
yum install mysql
           

rpm 本地安裝mysql

rpm -ivh mysql-community-common-5.7.16-1.el6.x86_64.rpm 
rpm -ivh mysql-community-libs-5.7.16-1.el6.x86_64.rpm 
rpm -ivh mysql-community-client-5.7.16-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.16-1.el6.x86_64.rpm
           

3.啟動 重新開機 與 停止 mysql 服務

啟動mysql 服務 (在這裡,我們選擇啟動mysql服務)

service mysqld start
           

注意:如果我們是第一次啟動mysql服務,mysql伺服器會初始化顯示:

初始化 MySQL 資料庫: 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 localhost.localdomain 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 服務

service mysqld restart
           

停止mysql 服務

service mysqld stop
           

4.配置mysql資料庫密碼,并進入mysql資料庫

配置mysql資料庫密碼

mysqladmin -u root password 123456
           

進入mysql資料庫

mysql -u root -p
           

輸入密碼,進入資料庫。

5.開機自動啟動mysql服務

首先檢查是否開機啟動mysql服務

[[email protected] ~]# chkconfig --list | grep mysqld
mysqld          0:關閉  1:關閉  2:關閉  3:關閉  4:關閉  5:關閉  6:關閉   //現在都是關閉狀态
           

開機啟動mysql 服務

chkconfig mysqld on
           

大功告成

繼續閱讀