標籤:
一、通過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的安裝與配置