mysql5.7.13Generic安装步骤

来源:互联网 发布:linux解压缩命令 编辑:程序博客网 时间:2024/06/15 18:17

1.下载5.7.13Generic64位版本软件

具体链接地址:http://dev.mysql.com/downloads/mysql/。我在写这篇博客的时候刚好5.7.14出来了。

2.下载Generic版本

[root@localhost Csong]# lltotal 624872drwxr-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 mysqluid=27(mysql) gid=27(mysql) groups=27(mysql)

3.解压并拷贝至/usr/local/下,重命名为mysql文件夹,修改mysql文件夹的权限为mysql

[root@localhost local]# lltotal 4drwxr-xr-x.  2 root  root     6 Aug 12  2015 bindrwxr-xr-x.  2 root  root     6 Aug 12  2015 etcdrwxr-xr-x.  2 root  root     6 Aug 12  2015 gamesdrwxr-xr-x.  2 root  root     6 Aug 12  2015 includedrwxr-xr-x.  2 root  root     6 Aug 12  2015 libdrwxr-xr-x.  2 root  root     6 Aug 12  2015 lib64drwxr-xr-x.  2 root  root     6 Aug 12  2015 libexecdrwxr-xr-x. 11 mysql mysql 4096 Aug  4 23:05 mysqldrwxr-xr-x.  2 root  root     6 Aug 12  2015 sbindrwxr-xr-x.  5 root  root    46 Aug  2 16:18 sharedrwxr-xr-x.  2 root  root     6 Aug 12  2015 src[root@localhost local]# cd mysql/[root@localhost mysql]# lltotal 48drwxr-xr-x.  2 mysql mysql  4096 Aug  7 06:33 bin-rw-r--r--.  1 mysql mysql 17987 Aug  3 10:46 COPYINGdrwxr-xr-x.  3 mysql mysql    23 Aug  3 10:51 datadrwxr-xr-x.  2 mysql mysql    52 Aug  3 10:47 docsdrwxr-xr-x.  3 mysql mysql  4096 Aug  3 10:47 includedrwxr-xr-x.  5 mysql mysql  4096 Aug  3 10:46 libdrwxr-xr-x.  4 mysql mysql    28 Aug  3 10:47 man-rw-r--r--.  1 mysql mysql  2478 Aug  3 10:45 READMEdrwxr-xr-x. 28 mysql mysql  4096 Aug  3 10:46 sharedrwxr-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]# lltotal 12drwxr-x---. 5 mysql mysql 4096 Aug  7 07:35 datadrwxr-xr-x. 2 mysql mysql 4096 Aug  7 07:10 logs-rw-r--r--. 1 mysql mysql  376 Aug  5 14:02 mysql_3307.cnfdrwxr-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 = 3307server-id = 2socket = /tmp/mysql_3307.sockbinlog_format = mixedgtid-mode = off#gtid-mode=on  ##GTID type#enforce-gtid-consistency=on  ##GTID type#log_slave_updates  ##GTID typelog-bin = /data/mysql_3307/logs/mybinlogtmpdir = /data/mysql_3307/tmplog-error = error.loglog-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/dataGenerating 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  sysca-key.pem       error.log       ib_logfile1         public_key.pemca.pem           ib_buffer_pool  mysql               server-cert.pemclient-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 -pEnter password:         --注意,这里的密码,默认mysql会生成一个hash后的初始密码,密码在error.log中,这个error.log的位置在defaults-file中有定义。Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.13-logCopyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.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> exitBye[root@localhost mysql_3307]# /usr/local/mysql/bin/mysql -S /tmp/mysql_3307.sock -uroot -pEnter password: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 3Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.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';
这样就可以了。








0 0
原创粉丝点击