centos6.8 64 安装 mysql5.7

1. mysql 下载

首先我们进入MySQL的官网

http://www.mysql.com/downloads/mysql/
进入官网后选择适用于自己Linux版本的 mysql
176a07ff922849ebbde1d65e3621fa1c.png

1.1 接下来选择 mysql 的安装包,我选择的是 tar.gz

d16a56fdb69e43aca3784bc61e419203.png

1.2 进入下载页后点击直接下载即可。下载完毕后可以通过工具将安装包放入 Linux 系统

a2f9b5b774f541dcaed8e3777e6d7152.png

2. 进入 Linux 系统,查看 mysql 安装包

c7723d29d8274aeb9c0309073b1832a1.png

3. 创建 mysql 组和 mysql 用户,并且将 mysql 用户设置为系统用户,将 mysql 用户归为 mysql 组

 
groupadd mysql useradd -r -g mysql mysql 

216f249d60844a8a98563c809b0adc8f.png

4. 创建存放 mysql 的文件夹

 
mkdir -p /usr/local/mysql 

50628447ef5c41c49b960274fc4170c4.png

5. 将 mysql 安装包移动到 /usr/local/mysql

c3b53623ec9f40beb71f263ba751e5b2.png

6. 进入 /usr/local/mysql 目录,解压 mysql

解压命令:tar -xzvf 文件名
60909765c7a14ed3aa4da1bd889f89ae.png

7. 解压成功后查看 /usr/local/mysql 目录

ba2be32493c4443c8022803f7475c577.png

8. 将 mysql-5.7.16-linux 目录里的 mysql 安装文件全部移动至 /usr/local/mysql 目录

8.1 进入 mysql-5.7.16-linux 目录

8.2 mv * /user/local/mysql 移动全部

27877c4ca20f4c8a97c23fa8a1965c85.png

9. 现在可以将 mysql 的安装包与 mysql-5.7.16-linux 空目录删掉,

不想删掉的可以略过此步

c445a009ea0a4a42be43b9f28b959e8e.png

10. 在 /usr/local/mysql 目录创建 data 文件夹

cd214180c1454e37a5bb5ecae9f27021.png

11. 修改 /etc/my.cnf

ee7ead51a4944e5e8b64b93c8687388d.png

 
basedir=/usr/local/mysql/ datadir=/usr/local/mysql/data 

08d6ff5c579e4d399107d73e9a3b2f1a.png

12. 修改 mysql 目录权限

898b1dda9af4409482484b781f1e19c7.png

13. 初始化 mysql

执行 mysql_install_db 命令的时候后面的参数一定要加上,--user 代表运行用户,--basedir 代表 MySql 安装目录,--datadir 代表数据库数据所在目录

 
命令(在mysql目录执行): bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 

949b6ba3ae5e47a184b469f2e8f0bec0.png

14. 添加开机启动

执行命令:

 
cp support-files/mysql.server /etc/init.d/mysql 

把启动脚本放到开机初始化目录

7a6701aba4be4fb1bdeb54d0159269ed.png

15. 开启 mysql

 
service mysql start 

b349716133924e5eb29c96f2f0ee60f4.png

配置文件 /etc/my.cnf

 
[client] socket=/var/lib/mysql/mysql.sock  [mysqld] basedir=/usr/local/mysql datadir=/usr/local/mysql/data socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 lower_case_table_names=1  [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid 

16. 初始化密码

mysql5.7 会生成一个初始化密码,而在之前的版本首次登陆不需要登录。

 
[root@localhost bin]$ cat /root/.mysql_secret # Password set foruser 'root@localhost'at 2016-06-01 15:23:25 ,xxxxxR5H9 [root@localhost bin]$./mysql -uroot -p Enter password: Welcome tothe MySQL monitor. Commands end with; or \g. Your MySQL connection id is 2 Server version: 5.7.12 Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle isa registered trademark ofOracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement. mysql> SET PASSWORD = PASSWORD('123456'); Query OK, 0rows affected, 1 warning (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) 

17. 添加远程访问权限

 
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 host = '%'where user = 'root'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select host, user from user; +-----------+-----------+| host | user | +-----------+-----------+ | % | root || localhost | mysql.sys | +-----------+-----------+//重启生效 /etc/init.d/mysqld restart 

设置开机启动

添加执行权限

chmod +x /etc/init.d/mysql

添加到服务

chkconfig --add mysql

设置开机启动

chkconfig mysql on
Jdk 安装

ps :

export JAVA_HOME=/usr/local/java/jdk1.7.0_45

export JRE_HOME=/usr/local/java/jdk1.7.0_45/jre

export CLASSPATH=.:JAVAHOME/lib/dt.jar:



作者:cbxjj
链接:https://hacpai.com/article/1492794464875
来源:黑客派
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

posted @ 2018-07-10 10:04  tracy11111  阅读(264)  评论(0)    收藏  举报