安裝環境:系統是 centos6.5html
一、下載mysql
下載地址:http://dev.mysql.com/downloads/mysql/5.6.html#downloadslinux
下載版本:我這裏選擇的5.6.33,通用版,linux下64位sql
也能夠直接複製64位的下載地址,經過命令下載:wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz數據庫
二、解壓centos
1
2
3
4
|
#解壓
tar
-zxvf mysql-5.6.33-linux-glibc2.5-x86_64. tar .gz
#複製解壓後的mysql目錄
cp
-r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql
|
三、添加用戶組和用戶bash
1
2
3
4
|
#添加用戶組
groupadd mysql
#添加用戶mysql 到用戶組mysql
useradd
-g mysql mysql
|
四、安裝post
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
cd
/usr/local/mysql/ <br> mkdir . /data/mysql
chown
-R mysql:mysql ./
.
/scripts/mysql_install_db
--user=mysql --datadir= /usr/local/mysql/data/mysql
cp
support-files /mysql .server /etc/init .d /mysqld
chmod
755 /etc/init .d /mysqld
cp
support-files /my-default .cnf /etc/my .cnf
#修改啓動腳本
vi
/etc/init .d /mysqld
#修改項:
basedir=
/usr/local/mysql/
datadir=
/usr/local/mysql/data/mysql
#啓動服務
service mysqld start
#測試鏈接
.
/mysql/bin/mysql
-uroot
#重點配置修改
#加入環境變量,編輯 /etc/profile,這樣能夠在任何地方用mysql命令了
vi
/etc/profile
export
PATH=$PATH: /usr/local/mysql/bin
source /etc/profile
#啓動mysql
service mysqld start
#關閉mysql
service mysqld stop
#查看運行狀態
service mysqld status
|
五、錯誤測試
5.1 sqlyog鏈接時,報1130錯誤,是因爲沒有給遠程鏈接的用戶權限問題spa
解決1:更改 ‘mysql’數據庫‘user’表‘host’項,從‘localhost’改爲‘%’。
use mysql;
select 'host' from user where user='root'; update user set host = '%' where user ='root'; flush privileges;
解決2:直接受權
GRANT ALL PRIVILEGES ON *.* TO ‘root’@'%’ IDENTIFIED BY ‘youpassword’ WITH GRANT OPTION;
5.2 密碼修改
#選擇數據庫
use mysql;
#修改密碼
update user set password = password('newpwd') where user='root';
#當即生效
flush privileges;
5.3 安裝時的一些錯誤
-bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter: 沒有那個文件或目錄
解決: yum -y install perl perl-devel
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解決:yum -y install libaio-devel
六、其餘
6.1 配置環境變量
vi + /etc/profile
export PATH=....:/usr/local/mysql/bin