這篇文章主要介紹“CentOS6下怎么用RPM方式安裝MySQL5.6”,在日常操作中,相信很多人在CentOS6下怎么用RPM方式安裝MySQL5.6問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”CentOS6下怎么用RPM方式安裝MySQL5.6”的疑惑有所幫助!接下來(lái),請(qǐng)跟著小編一起來(lái)學(xué)習(xí)吧!
寧陜ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來(lái)市場(chǎng)廣闊!成為成都創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!
CentOS 6 下RPM方式安裝MySQL5.6
1. 下載Linux對(duì)應(yīng)的RPM包,如:CentOS6.7_64對(duì)應(yīng)的RPM包,如下:
[root@mysql ~]# ll
總用量 113808
-rw-------. 1 root root 1434 12月 13
18:47 anaconda-ks.cfg
-rw-r--r--. 1 root root 42556 12月 13 18:47 install.log
-rw-r--r--. 1 root root 10033 12月 13 18:45 install.log.syslog
-rw-r--r--. 1 root root 23135399 12月 13 18:56 MySQL-client-5.6.25-1.linux_glibc2.5.x86_64.rpm
-rw-r--r--. 1 root root 4586217 12月 13 18:56 MySQL-devel-5.6.25-1.linux_glibc2.5.x86_64.rpm
-rw-r--r--. 1 root root 88715219 12月 13 18:56 MySQL-server-5.6.25-1.linux_glibc2.5.x86_64.rpm
2. 檢查MySQL及相關(guān)RPM包,是否安裝,如果有安裝,則移除(rpm –e 名稱)
[root@mysql ~]# rpm -qa | grep -i mysql
mysql-libs-5.1.73-5.el6_6.x86_64
[root@mysql ~]# yum -y remove mysql-libs*
已加載插件:fastestmirror,
refresh-packagekit, security
設(shè)置移除進(jìn)程
解決依賴關(guān)系
。。。。。
完畢!
3. 安裝MySQL
[root@mysql ~]# rpm -ivh MySQL-server-5.6.25-1.linux_glibc2.5.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
warning: user mysql does not exist - using root
warning: group mysql does not exist - using root
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
[root@mysql ~]# rpm -ivh MySQL-devel-5.6.25-1.linux_glibc2.5.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-devel ########################################### [100%]
[root@mysql ~]# rpm -ivh MySQL-client-5.6.25-1.linux_glibc2.5.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
4. 初始化MySQL及設(shè)置密碼
[root@mysql ~]# /usr/bin/mysql_install_db -- mysql_install_db腳本來(lái)生成帳戶和相應(yīng)權(quán)限許可表
WARNING: The host 'mysql' could not be looked up with /usr/bin/resolveip.
This probably means that your libc libraries are not 100 % compatible
。。省略輸出。。
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
[root@mysql ~]# service mysql start
Starting MySQL. SUCCESS!
[root@mysql ~]# cat /root/.mysql_secret --查看root賬號(hào)密碼
# The random password set for the root user at Tue Dec 13 18:59:06 2016 (local
time): 7MhtyX3aZEl9OUf8
[root@mysql ~]# mysql -uroot -p
Enter password: --(此處復(fù)制粘貼 7MhtyX3aZEl9OUf8)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.25
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
說(shuō)明: 出現(xiàn)mysql>
表示一切順利成功。
mysql> SET PASSWORD = PASSWORD('123456'); --設(shè)置密碼為123456
5. 允許遠(yuǎn)程登陸
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select host,user,password from user;
+-----------+------+-------------------------------------------+
| host | user | password |
+-----------+------+-------------------------------------------+
| localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| mysql | root | *6D95CDA252C85345E8BC1C4168E962D3949C30F9 |
| 127.0.0.1 | root | *6D95CDA252C85345E8BC1C4168E962D3949C30F9 |
| ::1 | root | *6D95CDA252C85345E8BC1C4168E962D3949C30F9 |
+-----------+------+-------------------------------------------+
4 rows in set (0.00 sec)
mysql> update user set password=password('123456') where user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 4 Changed: 3 Warnings: 0
mysql> update user set host='%' where user='root' and host='localhost';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
6. 設(shè)置開機(jī)自啟動(dòng)
[root@mysql ~]# chkconfig mysql on
[root@mysql ~]# chkconfig --list | grep mysql
mysql 0:關(guān)閉 1:關(guān)閉 2:啟用 3:啟用 4:啟用 5:啟用 6:關(guān)閉
7. MySQL的默認(rèn)安裝位置
/var/lib/mysql/ #數(shù)據(jù)庫(kù)目錄
/usr/share/mysql #配置文件目錄
/usr/bin #相關(guān)命令目錄
/etc/init.d/mysql #啟動(dòng)腳本
8. 更改MySQL目錄與字符集
[root@mysql ~]# cd /home --home目錄下建立data目錄
[root@mysql home]# mkdir data
[root@mysql ~]# service mysql stop --把MySQL服務(wù)進(jìn)程停掉
Shutting down MySQL.. SUCCESS!
[root@mysql home]# mv /var/lib/mysql /home/data --把/var/lib/mysql整個(gè)目錄移到/home/data
如果/etc/目錄下沒有my.cnf配置文件,請(qǐng)到/usr/share/mysql/下找到*.cnf文件,拷貝其中一個(gè)到/etc/并改名為my.cnf)中
[root@mysql ~]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf --修改配置文件位置
配置/etc/my.cnf文件,修改數(shù)據(jù)存放路徑、mysql.sock路徑以及默認(rèn)編碼utf-8.
[client]
password = 123456
port = 3306
default-character-set=utf8
[mysqld]
port = 3306
socket =
/home/data/mysql/mysql.sock
character_set_server=utf8
character_set_client=utf8
collation-server=utf8_general_ci
#(注意linux下mysql安裝完后是默認(rèn):表名區(qū)分大小寫,列名不區(qū)分大小寫; 0:區(qū)分大小寫,1:不區(qū)分大小寫)
lower_case_table_names=1
#(設(shè)置最大連接數(shù),默認(rèn)為 151,MySQL服務(wù)器允許的最大連接數(shù)16384; )
max_connections=1000
[mysql]
default-character-set = utf8
socket =
/home/data/mysql/mysql.sock
查看字符集
show variables like '%collation%';
show variables like '%char%';
9. 修改MySQL啟動(dòng)腳本/etc/rc.d/init.d/mysql
最后,需要修改MySQL啟動(dòng)腳本/etc/rc.d/init.d/mysql,把其中datadir=/var/lib/mysql一行中,等號(hào)右邊的路徑改成你現(xiàn)在的實(shí)際存放路徑:home/data/mysql。
[root@test1 etc]# vi /etc/rc.d/init.d/mysql
#datadir=/var/lib/mysql ?。ㄗ⑨尨诵校?br/>datadir=/home/data/mysql (加上此行)
10. 重新啟動(dòng)MySQL服務(wù)
[root@mysql ~]# service mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
OK 一切成功
到此,關(guān)于“CentOS6下怎么用RPM方式安裝MySQL5.6”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!
分享題目:CentOS6下怎么用RPM方式安裝MySQL5.6
鏈接分享:http://aaarwkj.com/article48/pcdchp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司、做網(wǎng)站、標(biāo)簽優(yōu)化、微信小程序、網(wǎng)站設(shè)計(jì)、用戶體驗(yàn)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)