mysql5.7.13Generic安裝步驟

1.下載5.7.13Generic64位版本軟件

具體鏈接地址:http://dev.mysql.com/downloads/mysql/。我在寫這篇博客的時候剛好5.7.14出來了。

2.下載Generic版本

[root@localhost Csong]# ll
total 624872
drwxr-xr-x. 9 7161 wheel      4096 May 25 15:04 mysql-5.7.13-linux-glibc2.5-x86_64
-rw-r--r--. 1 root root  639864682 Aug  3 10:42 mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz

3.用root登入Linux,並創建mysql用戶組和mysql用戶

[root@localhost local]# id mysql
uid=27(mysql) gid=27(mysql) groups=27(mysql)

3.解壓並拷貝至/usr/local/下,重命名爲mysql文件夾,修改mysql文件夾的權限爲mysql

[root@localhost local]# ll
total 4
drwxr-xr-x.  2 root  root     6 Aug 12  2015 bin
drwxr-xr-x.  2 root  root     6 Aug 12  2015 etc
drwxr-xr-x.  2 root  root     6 Aug 12  2015 games
drwxr-xr-x.  2 root  root     6 Aug 12  2015 include
drwxr-xr-x.  2 root  root     6 Aug 12  2015 lib
drwxr-xr-x.  2 root  root     6 Aug 12  2015 lib64
drwxr-xr-x.  2 root  root     6 Aug 12  2015 libexec
drwxr-xr-x. 11 mysql mysql 4096 Aug  4 23:05 mysql
drwxr-xr-x.  2 root  root     6 Aug 12  2015 sbin
drwxr-xr-x.  5 root  root    46 Aug  2 16:18 share
drwxr-xr-x.  2 root  root     6 Aug 12  2015 src
[root@localhost local]# cd mysql/
[root@localhost mysql]# ll
total 48
drwxr-xr-x.  2 mysql mysql  4096 Aug  7 06:33 bin
-rw-r--r--.  1 mysql mysql 17987 Aug  3 10:46 COPYING
drwxr-xr-x.  3 mysql mysql    23 Aug  3 10:51 data
drwxr-xr-x.  2 mysql mysql    52 Aug  3 10:47 docs
drwxr-xr-x.  3 mysql mysql  4096 Aug  3 10:47 include
drwxr-xr-x.  5 mysql mysql  4096 Aug  3 10:46 lib
drwxr-xr-x.  4 mysql mysql    28 Aug  3 10:47 man
-rw-r--r--.  1 mysql mysql  2478 Aug  3 10:45 README
drwxr-xr-x. 28 mysql mysql  4096 Aug  3 10:46 share
drwxr-xr-x.  2 mysql mysql  4096 Aug  3 10:46 support-files

4.創建defaults-file文件

這個文件在初始化的時候可以用到,啓動的時候也可以用到,你可以改成你想要的任何名字,我這裏規定了我的mysql的端口號是3307,並且我單獨在根目錄下創建了一個給mysql使用的數據目錄,並且創建了我的defaults-file,名字爲mysql_3307.cnf。
[root@localhost mysql_3307]# pwd
/data/mysql_3307
[root@localhost mysql_3307]# ll
total 12
drwxr-x---. 5 mysql mysql 4096 Aug  7 07:35 data
drwxr-xr-x. 2 mysql mysql 4096 Aug  7 07:10 logs
-rw-r--r--. 1 mysql mysql  376 Aug  5 14:02 mysql_3307.cnf
drwxr-xr-x. 2 mysql mysql    6 Aug  7 07:10 tmp
[root@localhost mysql_3307]# cat mysql_3307.cnf 
[mysqld]
basedir = /usr/local/mysql/
datadir = /data/mysql_3307/data/
port = 3307
server-id = 2
socket = /tmp/mysql_3307.sock
binlog_format = mixed
gtid-mode = off
#gtid-mode=on  ##GTID type
#enforce-gtid-consistency=on  ##GTID type
#log_slave_updates  ##GTID type
log-bin = /data/mysql_3307/logs/mybinlog
tmpdir = /data/mysql_3307/tmp
log-error = error.log
log-output = file

5.初始化mysqld

[root@localhost mysql_3307]# /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql_3307/mysql_3307.cnf --initialize --user=mysql
[root@localhost mysql_3307]# /usr/local/mysql/bin/mysql_ssl_rsa_setup --basedir=/usr/local/mysql/ --datadir=/data/mysql_3307/data
Generating a 2048 bit RSA private key
...........................+++
.......................+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
.............+++
...............+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
..........+++
................................................................+++
writing new private key to 'client-key.pem'
-----
[root@localhost mysql_3307]# ls data/
auto.cnf         client-key.pem  ib_logfile0         private_key.pem  sys
ca-key.pem       error.log       ib_logfile1         public_key.pem
ca.pem           ib_buffer_pool  mysql               server-cert.pem
client-cert.pem  ibdata1         performance_schema  server-key.pem

6.啓動mysql實例

[root@localhost mysql_3307]# /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql_3307/mysql_3307.cnf --user=mysql &
[1] 14452

7.連接mysql

[root@localhost mysql_3307]# /usr/local/mysql/bin/mysql -S /tmp/mysql_3307.sock -uroot -p
Enter password:         --注意,這裏的密碼,默認mysql會生成一個hash後的初始密碼,密碼在error.log中,這個error.log的位置在defaults-file中有定義。
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.13-log

Copyright (c) 2000, 2016, 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> set password = password('123456');   --注意,最好在登入後,將自己的密碼修改一下。
Query OK, 0 rows affected, 1 warning (0.12 sec)

mysql> exit
Bye
[root@localhost mysql_3307]# /usr/local/mysql/bin/mysql -S /tmp/mysql_3307.sock -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.13-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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> 
至此,mysql5.7.13已經安裝完畢了。但是,現在mysql中的root用戶,遠程是登入不了的,因爲權限沒開放。
可以在mysql命令窗口中輸入grant all on *.* to 'root'@'%' identified by '123456';
這樣就可以了。








發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章