下載地址:http://dev.mysql.com/downloads/mysql/#downloads 選擇 Linux - Generic,php
按照你的系統選擇3二、64版本html
http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.17-linux-glibc2.5-i686.tar.gznode
http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.17-linux-glibc2.5-x86_64.tar.gzmysql
如下爲網絡上搜集的綠色版安裝方式步驟。linux
摘錄(http://www.cnblogs.com/gaojian/archive/2013/09/12/3317000.html)c++
1)下載:sql
在mysql的網站上,下載 mysql-5.6.13-linux-glibc2.5-x86_64.tar.gz 數據庫
好比拷貝到 /soft/mysql5/ 目錄下。windows
2)解壓:服務器
[root@server local]#cd /usr/local
[root@server local]#tar zxvf /soft/mysql5/mysql-5.6.13-linux-glibc2.5-x86_64.tar.gz
3)創建軟連接:
[root@server local]#ln -s mysql-5.6.13-linux-glibc2.5-x86_64 mysql
查看:
[root@server local]# ls -lrt mysql
lrwxrwxrwx 1 root root 36 9月 12 13:22 mysql -> ./mysql-5.6.13-linux-glibc2.5-x86_64
[root@server local]#
4)創建mysql相關的用戶和組:
[root@server local]#groupadd mysql
[root@server local]#useradd -r -g mysql mysql
5)生成數據庫:
[root@server local]# cd mysql
[root@server local]# chown -R mysql .
[root@server local]#chgrp -R mysql .
[root@server local]# scripts/mysql_install_db --user=mysql
[root@server local]# chown -R root .
[root@server local]# chown -R mysql data
6)拷貝必要的文件(此爲可選步驟):
[root@server local]#cp support-files/mysql.server /etc/init.d/mysql.server
7)啓動數據庫:
[root@server local]bin/mysqld_safe --user=mysql &
8)訪問數據庫:
[root@server ~]# mysql --user=mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
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.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+
2 rows in set (0.00 sec)
mysql> quit
Bye
[root@server ~]#
9)關閉數據庫時,發現沒法關閉數據庫,因而強制關閉進程,而後退出。
10)設置權限:
從新啓動數據庫(帶 --skip-grant-tables參數):
[root@server ~]# mysqld_safe --skip-grant-tables &
[1] 3140
[root@server ~]# 130912 14:49:51 mysqld_safe Logging to '/usr/local/mysql/data/server.gao.err'.
130912 14:49:51 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
設置root用戶的口令(被要求Enter password的時候,直接按回車鍵就過去了):
[root@server ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
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.
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> update user set password=password("abcdef") where user='root' and host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
[root@server ~]#
爲了驗證是否能夠正常關閉,再次從新啓動來看一下:
[root@server ~]# mysqld_safe --skip-grant-tables
130912 14:57:36 mysqld_safe Logging to '/usr/local/mysql/data/server.gao.err'.
130912 14:57:36 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
[root@server ~]#
而後運行:
[root@server ~]# mysqladmin -uroot shutdown
[root@server ~]#
成功關閉。
下一次,徹底正常啓動,看可否關閉:
[root@server ~]# mysqld_safe
130912 15:01:26 mysqld_safe Logging to '/usr/local/mysql/data/server.gao.err'.
130912 15:01:26 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
[root@server ~]# mysqladmin -uroot -p shutdown
Enter password:
[root@server ~]#
關閉成功了。
[做者 高健@博客園 luckyjackgao@gmail.com]
摘錄(http://www.cnblogs.com/GeeWu/archive/2011/05/17/linux_mysql_compile.html)
1, 下載。
這裏下載http://dev.mysql.com/downloads/mirror.php?id=402502。
2, 安裝。
下載到本地解壓:
tar -xvf MySQL-5.5.12-1.rhel5.x86_64.tar
安裝如下rpm
rpm -ivh MySQL-devel-5.5.12-1.rhel5.x86_64.rpm
rpm -ivh MySQL-shared-5.5.12-1.rhel5.x86_64.rpm
rpm -ivh MySQL-client-5.5.12-1.rhel5.x86_64.rpm
rpm -ivh MySQL-server-5.5.12-1.rhel5.x86_64.rpm
3, 配置用戶和用戶組。
groupadd mysql
useradd mysql –g mysql
4, 配置mysql配置。
cd /usr/share/mysql/
cp my-medium.cnf /etc/my.cnf #我這裏僅僅用來演示應用程序的。
5, 運行mysql
mysqld_safe &
6, 配置mysql root用戶
mysqladmin -uroot password 'password'
7, 設置遠程用戶
create user 'geewu'@'%' IDENTIFIED BY 'password';
GRANT ALL ON *.* TO 'geewu'@'%';
Mysql命令行編譯
groupadd mysql
useradd -s /bin/false -g mysql -pmysql mysql
#安裝mysql到home/work/local/mysql
./configure --prefix=/home/work/local/mysql \
--with-unix-socket-path=/home/work/local/mysql/tmp/mysql.sock \
--with-big-tables --with-plugins=all --with-client-ldflags=all-static --with-mysqld-ldflags=all-static
make; make install
1. -static 13%
--with-client-ldflags=-all-static
--with-mysqld-ldflags=-all-static
靜態連接提升13%性能
2. -pgcc 1%
CFLAGS="-O3 -mpentiumpro -mstack-align-double" CXX=gcc \
CXXFLAGS="-O3 -mpentiumpro -mstack-align-double \
-felide-constructors -fno-exceptions -fno-rtti"
若是是Inter處理器,使用pgcc提升1%性能
3. Unix Socket 7.5%
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
使用unix套接字連接提升7.5%性能,因此在windows下mysql性能確定不如unix下面
4. --enable-assembler
容許使用匯編模式(優化性能)
cd /home/work/local/mysql
bin/mysql_install_db --user=mysql // 安裝默認數據庫
cp share/mysql/my-medium.cnf /etc/my.cnf //複製配置文件(可能須要適當修改)
cp share/mysql/mysql.server /etc/init.d/mysqld //複製mysql啓動腳本
chmod 755 /etc/init.d/mysqld //更改mysql啓動腳本權限,執行權限必須
chkconfig --add mysqld //添加mysql服務
chkconfig --level 35 mysqld on //設置服務在運行級3,5啓動
service mysqld start //啓動服務
摘自(http://my.oschina.net/u/585378/blog/110473)
使用yum安裝
安裝mysql客戶端:
yum install mysql
安裝mysql 服務器端:
yum install mysql-server
yum install mysql-devel
有點windows下軟件安裝的感受,比較簡便。
本身習慣了之前服務器數據庫存放路徑爲/data/mysql,套接字/tmp/mysql.sock
經過yum安裝,數據庫存放路徑/var/lib/mysql,終究感受不是那麼習慣。
摘自(http://www.cnblogs.com/xiongpq/p/3384681.html)
====================================================================================
CentOS 6.4下經過yum安裝的MySQL是5.1版的,比較老,因此就想經過源代碼安裝高版本的5.6.14。
使用下面的命令檢查是否安裝有MySQL Server
rpm -qa | grep mysql
有的話經過下面的命令來卸載掉
rpm -e mysql //普通刪除模式 rpm -e --nodeps mysql // 強力刪除模式,若是使用上面命令刪除時,提示有依賴的其它文件,則用該命令能夠對其進行強力刪除
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.14.tar.gz tar xvf mysql-5.6.14.tar.gz cd mysql-5.6.14
cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DSYSCONFDIR=/etc \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \ -DMYSQL_TCP_PORT=3306 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci\
-DENABLE_DOWNLOADS=1
make && make install
編譯的參數能夠參考http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html。
整個過程須要30分鐘左右……漫長的等待
使用下面的命令查看是否有mysql用戶及用戶組
cat /etc/passwd 查看用戶列表 cat /etc/group 查看用戶組列表
若是沒有就建立
groupadd mysql useradd -g mysql mysql
修改/usr/local/mysql權限
chown -R mysql:mysql /usr/local/mysql
修改/usr/local/mysql權限
進入安裝路徑
cd /usr/local/mysql
進入安裝路徑,執行初始化配置腳本,建立系統自帶的數據庫和表
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
注:在啓動MySQL服務時,會按照必定次序搜索my.cnf,先在/etc目錄下找,找不到則會搜索"$basedir/my.cnf",在本例中就是 /usr/local/mysql/my.cnf,這是新版MySQL的配置文件的默認位置!注意:在CentOS 6.4版操做系統的最小安裝完成後,在/etc目錄下會存在一個my.cnf,須要將此文件改名爲其餘的名字,如:/etc/my.cnf.bak,不然,該文件會干擾源碼安裝的MySQL的正確配置,形成沒法啓動。
添加服務,拷貝服務腳本到init.d目錄,並設置開機啓動
cp support-files/mysql.server /etc/init.d/mysql chkconfig mysql on service mysql start --啓動MySQL
MySQL啓動成功後,root默認沒有密碼,咱們須要設置root密碼。
設置以前,咱們須要先設置PATH,要不不能直接調用mysql
修改/etc/profile文件,在文件末尾添加
PATH=/usr/local/mysql/bin:$PATH export PATH
關閉文件,運行下面的命令,讓配置當即生效
source /etc/profile
如今,咱們能夠在終端內直接輸入mysql進入,mysql的環境了
執行下面的命令修改root密碼
mysql -uroot mysql> SET PASSWORD = PASSWORD('123456');
若要設置root用戶能夠遠程訪問,執行
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.16.%' IDENTIFIED BY 'password' WITH GRANT OPTION;
紅色的password爲遠程訪問時,root用戶的密碼,能夠和本地不一樣。
防火牆的3306端口默認沒有開啓,若要遠程訪問,須要開啓這個端口
打開/etc/sysconfig/iptables
在「-A INPUT –m state --state NEW –m tcp –p –dport 22 –j ACCEPT」,下添加:
-A INPUT m state --state NEW m tcp p dport 3306 j ACCEPT
而後保存,並關閉該文件,在終端內運行下面的命令,刷新防火牆配置:
service iptables restart
OK,一切配置完畢,你能夠訪問你的MySQL了~