Centos 6.5下安裝MySQL 5.6教程
1.下載Linux對應(yīng)的RPM包
http://dev.mysql.com/downloads/mysql/5.6.html
wget http://cdn.mysql.com//Downloads/MySQL-5.6/MySQL-5.6.33-1.el6.x86_64.rpm-bundle.tar
2.解壓tar包
tar -xvf MySQL-5.6.33-1.el6.x86_64.rpm-bundle.tar
3.安裝MySQL
rpm -ivh MySQL-server-5.6.33-1.el6.x86_64.rpm rpm -ivh MySQL-client-5.6.33-1.el6.x86_64.rpm rpm -ivh MySQL-devel-5.6.33-1.el6.x86_64.rpm
如果出現(xiàn):
error: Failed dependencies:
libaio.so.1()(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64
下載libaio
yum install libaio
如果出現(xiàn):
error: Failed dependencies:
libnuma.so.1()(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64
libnuma.so.1(libnuma_1.1)(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64
libnuma.so.1(libnuma_1.2)(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64
下載numactl
yum install numactl
4.初始化MySQL及設(shè)置密碼
/usr/bin/mysql_install_db service mysql start
如果啟動失敗可能是數(shù)據(jù)塊所在目錄沒有權(quán)限
cat /root/.mysql_secret #查看root賬號密碼
mysql> SET PASSWORD = PASSWORD('123456');
mysql> exit
如果.mysql_secret文件不存在,先停止MySQL進(jìn)入安全模式設(shè)置密碼
service mysql stop
mysqld_safe --skip-grant-tables&
mysql -u root mysql
mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root';
mysql> FLUSH PRIVILEGES;
5.允許遠(yuǎn)程登陸
mysql> use mysql; mysql> select host,user,password from user; mysql> update user set host='%' where user='root' and host='localhost'; mysql> flush privileges; mysql> exit
6.設(shè)置開機(jī)自啟動
chkconfig mysql on chkconfig --list | grep mysql mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
7.MySQL的默認(rèn)安裝位置
/var/lib/mysql/ #數(shù)據(jù)庫目錄 /usr/share/mysql #配置文件目錄 /usr/bin #相關(guān)命令目錄 /etc/init.d/mysql #啟動腳本
8.常用命令
1.使用客戶端工具連接到數(shù)據(jù)庫
mysql -u root -p
2.查看MySQL服務(wù)器中包含那些數(shù)據(jù)庫
mysql>SHOW DATABASES;
3.查看數(shù)據(jù)庫中的數(shù)據(jù)表信息
mysql>SHOW TABLES;
4.切換數(shù)據(jù)庫
mysql>USE mysql;
5.創(chuàng)建新的數(shù)據(jù)庫
mysql>CREATE DATABASE 數(shù)據(jù)庫名字;
6.創(chuàng)建新的數(shù)據(jù)表
mysql>CREATE TABLE 表名 (字段定義)
7.刪除一個數(shù)據(jù)表
mysql>DROP TABLE 數(shù)據(jù)庫名.表名;
8.刪除一個數(shù)據(jù)庫
mysql>DROP DATABASE 數(shù)據(jù)庫名
9.備份整個數(shù)據(jù)庫
mysqldump -u root -p auth > mysql-auth.sql
10.備份數(shù)據(jù)庫MYSQL中的user表
mysqldump -u root -p mysql user > mysql.host-user.sql
11.備份MYSQL服務(wù)器中所有數(shù)據(jù)庫
mysqldump -u root -p -all-databases > mysql-all.sql
12.恢復(fù)數(shù)據(jù)庫
mysql -u root -p [數(shù)據(jù)庫名]< mysql-all.sql
13.授予用戶權(quán)限
GRANT 權(quán)限列表 ON 數(shù)據(jù)庫名.表名 TO 用戶名@來源地址 [IDENTIFIED BY '密碼'] GRANT SELECT ON mysql.user TO daxiong@'localhost' IDENTIFIED BY'123456';
以上所述是小編給大家介紹的Centos 6.5下安裝MySQL 5.6教程,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對本站網(wǎng)站的支持!
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。
關(guān)注官方微信