RPM方式安装MySQL5.6和windows下安装mysql解压版
下載地址:
http://cdn.MySQL.com/archives/mysql-5.6/MySQL-server-5.6.13-1.el6.x86_64.rpm
http://cdn.mysql.com/archives/mysql-5.6/MySQL-devel-5.6.13-1.el6.x86_64.rpm
http://cdn.mysql.com/archives/mysql-5.6/MySQL-client-5.6.13-1.el6.x86_64.rpm
?
在RedHat?6.3下安裝MySQL-server-5.6.13-1.el6.x86_64.rpm
首先下載下面三個文件:
MySQL-client-5.6.13-1.el6.x86_64.rpm
MySQL-devel-5.6.13-1.el6.x86_64.rpm
MySQL-server-5.6.13-1.el6.x86_64.rpm
然后使用root賬號登陸,進行安裝:
1. 安裝server、devel、client:1. 安裝server、devel、client:
rpm -ivh --replacefiles MySQL-s*.rpm
rpm -ivh --replacefiles MySQL-d*.rpm
rpm -ivh --replacefiles MySQL-c*.rpm
?
?
發現缺libaio.so包
error: Failed dependencies:
/usr/bin/perl is needed by MySQL-server-5.6.22-1.el6.x86_64
libaio.so.1()(64bit) is needed by MySQL-server-5.6.22-1.el6.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.6.22-1.el6.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.6.22-1.el6.x86_64
error: Failed dependencies:
/usr/bin/perl is needed by MySQL-server-5.6.22-1.el6.x86_64
解決方法
[root@xcldtc5m mysql]# yum install libaio
[root@xcldtc5m mysql]# yum install perl
?
?
[root@localhost download]# rpm -ivh --replacefiles MySQL-server-5.6.13-1.el6.x86_64.rpm??
Preparing...? ? ? ? ? ? ? ? ########################################### [100%]??
? 1:MySQL-server? ? ? ? ? ########################################### [100%]??
[root@localhost download]# rpm -ivh --replacefiles MySQL-client-5.6.13-1.el6.x86_64.rpm??
Preparing...? ? ? ? ? ? ? ? ########################################### [100%]??
? 1:MySQL-client? ? ? ? ? ########################################### [100%]??
[root@localhost download]# rpm -ivh --replacefiles MySQL-devel-5.6.13-1.el6.x86_64.rpm??
Preparing...? ? ? ? ? ? ? ? ########################################### [100%]??
? 1:MySQL-devel? ? ? ? ? ? ########################################### [100%]
要移除安裝可以使用 rpm -e MySQL-server? 、 rpm -e MySQL-devel、MySQL-client即可;
2. 初始化數據庫:
/usr/bin/mysql_install_db
3. 啟動mysql服務:
service mysql start
使用命令ps -ef | grep mysql 查看mysql進程:
[root@localhost ~]# ps -ef | grep mysql??
root? ? 26047? ? 1? 0 18:14 pts/12? 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid??
mysql? ? 26227 26047? 0 18:14 pts/12? 00:00:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/lib/mysql/localhost.localdomain.pid --socket=/var/lib/mysql/mysql.sock??
root? ? 26545 24726? 0 18:27 pts/8? ? 00:00:00 grep mysql
4.第一次登陸設置root密碼:
首先查看 cat /root/.mysql_secret
root@localhost ~]# cat /root/.mysql_secret??
# The random password set for the root user at Fri Aug 30 15:57:18 2013 (local time): fMYcarvB
然后命令行:mysql -u root -p ,然后輸入上面的密碼即可:
[root@localhost ~]# mysql -u root -p??
Enter password:??
Welcome to the MySQL monitor.? Commands end with ; or \g.??
Your MySQL connection id is 5??
Server version: 5.6.13 MySQL Community Server (GPL)??
??
Copyright (c) 2000, 2013,?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.
設置root密碼:
SET PASSWORD=password('123456');
退出,重新登陸即可使用新的密碼登陸;
5. 設置遠程登陸:
使用root登陸到mysql后
?
mysql> update user set host='%' where user='root';??
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'??
mysql> select host,user from user;??
+-----------------------+------+??
| host? ? ? ? ? ? ? ? ? | user |??
+-----------------------+------+??
| %? ? ? ? ? ? ? ? ? ? | root |??
| 127.0.0.1? ? ? ? ? ? | root |??
| 192.168.128.142? ? ? | root |??
| ::1? ? ? ? ? ? ? ? ? | root |??
| localhost.localdomain | root |??
+-----------------------+------+??
5 rows in set (0.00 sec)
然后:
mysql> grant all privileges on *.* to 'root'@'%' with grant option;??
Query OK, 0 rows affected (0.08 sec)??
??
mysql> exit??
Bye??
[root@localhost ~]# service mysql restart??
Shutting down MySQL.. SUCCESS!??
Starting MySQL.. SUCCESS!??
重啟mysql即可遠程登陸。
?
如果遠程還是無法連接,請檢查防火墻是否開啟
/etc/init.d/iptables ?status
如果開啟 請關閉
/etc/init.d/iptables stop
?
###########################################################
?
RPM方式安裝MySQL5.6
a.?檢查MySQL及相關RPM包,是否安裝,如果有安裝,則移除(rpm?–e?名稱)
| 1 | [root@localhost ~]# rpm -qa | grep -i mysql |
| 2 | mysql-libs-5.1.66-2.el6_3.x86_64 |
| 3 | [root@localhost ~]# yum -y remove mysql-libs* |
b. 下載Linux對應的RPM包,如:CentOS6.4_64對應的RPM包,如下:
| 1 | [root@localhost rpm]# ll |
| 2 | total 74364 |
| 3 | -rw-r--r--. 1 root root 18442536 Dec 11 20:19 MySQL-client-5.6.15-1.el6.x86_64.rpm |
| 4 | -rw-r--r--. 1 root root? 3340660 Dec 11 20:06 MySQL-devel-5.6.15-1.el6.x86_64.rpm |
| 5 | -rw-r--r--. 1 root root 54360600 Dec 11 20:03 MySQL-server-5.6.15-1.el6.x86_64.rpm |
c.?安裝MySQL
| 1 | [root@localhost rpm]# rpm -ivh MySQL-server-5.6.15-1.el6.x86_64.rpm |
| 2 | [root@localhost rpm]# rpm -ivh MySQL-devel-5.6.15-1.el6.x86_64.rpm |
| 3 | [root@localhost rpm]# rpm -ivh MySQL-client-5.6.15-1.el6.x86_64.rpm |
| 4 | #修改配置文件位置 |
| 5 | [root@localhost rpm]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf |
d.?初始化MySQL及設置密碼
| 1 | [root@localhost rpm]# /usr/bin/mysql_install_db |
| 2 | [root@localhost rpm]# service mysql start |
| 3 | [root@localhost rpm]# cat /root/.mysql_secret? #查看root賬號密碼 |
| 4 | # The random password set for the root user at Wed Dec 11 23:32:50 2013 (local time): qKTaFZnl |
| 5 | [root@localhost ~]# mysql -uroot –pqKTaFZnl |
| 6 | mysql> SET PASSWORD = PASSWORD('123456');????#設置密碼為123456 |
| 7 | mysql>?exit |
| 8 | [root@localhost ~]# mysql -uroot -p123456 |
e.?允許遠程登陸
| 01 | mysql> use mysql; |
| 02 | mysql>?select?host,user,password from user; |
| 03 | +-----------------------+------+-------------------------------------------+ |
| 04 | | host????????????????? | user | password????????????????????????????????? | |
| 05 | +-----------------------+------+-------------------------------------------+ |
| 06 | | localhost???????????? | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | |
| 07 | | localhost.localdomain | root | *1237E2CE819C427B0D8174456DD83C47480D37E8 | |
| 08 | | 127.0.0.1???????????? | root | *1237E2CE819C427B0D8174456DD83C47480D37E8 | |
| 09 | | ::1?????????????????? | root | *1237E2CE819C427B0D8174456DD83C47480D37E8 | |
| 10 | +-----------------------+------+-------------------------------------------+ |
| 11 | ? |
| 12 | mysql> update user?set?password=password('123456') where user='root'; |
| 13 | mysql> update user?set?host='%'?where user='root'?and host='localhost'; |
| 14 | mysql> flush privileges; |
| 15 | mysql>?exit |
f.?設置開機自啟動
| 1 | [root@localhost ~]# chkconfig mysql on |
| 2 | [root@localhost ~]# chkconfig --list | grep mysql |
| 3 | mysql?????????? 0:off?? 1:off?? 2:on??? 3:on??? 4:on??? 5:on??? 6:off |
g.?MySQL的默認安裝位置
?
| 1 | /var/lib/mysql/???????????????#數據庫目錄 |
| 2 | /usr/share/mysql??????????????#配置文件目錄 |
| 3 | /usr/bin?????????????????????#相關命令目錄 |
| 4 | /etc/init.d/mysql??????????????#啟動腳本 |
?
?
?
?
修改字符集和數據存儲路徑
配置/etc/my.cnf文件,修改數據存放路徑、mysql.sock路徑以及默認編碼utf-8.
[html]?view plaincopy?
?
查看字符集
show variables like '%collation%';
show variables like '%char%';
?
?###########################################################
windows下安裝mysql解壓版
在windows下安裝mysql解壓版很簡單,分分鐘的事情,但是要使用好mysql,還是要多加以練習才行。下面說下安裝步驟。
????1、到官網下載最新的mysql版本,并解壓到任意路徑,比如:D:\Program Files\mysql\mysql-5.6.11-win32
????2、設置環境變量:新建變量名:MYSQL_HOME,值為你解壓的路徑:D:\Program Files\mysql\mysql-5.6.11-win32
????3、然后在系統變量path中添加:“;%MYSQL_HOME%\bin“,
????4、打開mysql根目錄,會發現有my-default.ini文件,復制然后重命名為my.ini
????5、在my.ini中添加如下內容:
????
[mysqld] #設置字符集為utf8 loose-default-character-set?=?utf8 basedir?=?D:/Program?Files/mysql/mysql-5.6.11-win32 datadir?=?D:/Program?Files/mysql/mysql-5.6.11-win32/data [client] loose-default-character-set?=?utf8 [mysql] loose-default-character-set?=?utf8 [WinMySQLadmin] server?=?D:/Program?Files/mysql/mysql-5.6.11-win32/bin/mysqld.exe?
????6、打開命令提示符,切換到D:\Program Files\mysql\mysql-5.6.11-win32\bin目錄下,然后執行mysqld -install安裝mysql服務。執行成功后會提示:service successfully installed。如果想卸載mysql服務,執行mysqld -remove即可。
????7、啟動mysql服務:net start mysql
? ? 8、默認情況下root是空密碼,給root設置密碼:mysqladmin -u root -p password "新密碼"
? ? 9、然后在命令提示符下執行mysql命令既可進入mysql,然后進行各種操作(建表、查詢之類的)
????最后推薦兩篇mysql操作連接:
????1、快速入門:http://www.cnblogs.com/mr-wid/archive/2013/05/09/3068229.html#c4
????2、深入研究:http://dev.mysql.com/doc/refman/5.1/zh/tutorial.html#database-use?
總結
以上是生活随笔為你收集整理的RPM方式安装MySQL5.6和windows下安装mysql解压版的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 初识React Native虚拟DOM节
- 下一篇: Python之SQLAlchemy学习