centos6.8 64 安装 mysql5.7
1. mysql 下载
首先我们进入MySQL的官网
http://www.mysql.com/downloads/mysql/
进入官网后选择适用于自己Linux版本的 mysql
1.1 接下来选择 mysql 的安装包,我选择的是 tar.gz
1.2 进入下载页后点击直接下载即可。下载完毕后可以通过工具将安装包放入 Linux 系统
2. 进入 Linux 系统,查看 mysql 安装包
3. 创建 mysql 组和 mysql 用户,并且将 mysql 用户设置为系统用户,将 mysql 用户归为 mysql 组
groupadd mysql useradd -r -g mysql mysql

4. 创建存放 mysql 的文件夹
mkdir -p /usr/local/mysql

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

6. 进入 /usr/local/mysql 目录,解压 mysql
解压命令:tar -xzvf 文件名
7. 解压成功后查看 /usr/local/mysql 目录
8. 将 mysql-5.7.16-linux 目录里的 mysql 安装文件全部移动至 /usr/local/mysql 目录
8.1 进入 mysql-5.7.16-linux 目录
8.2 mv * /user/local/mysql 移动全部
9. 现在可以将 mysql 的安装包与 mysql-5.7.16-linux 空目录删掉,
不想删掉的可以略过此步
10. 在 /usr/local/mysql 目录创建 data 文件夹
11. 修改 /etc/my.cnf
basedir=/usr/local/mysql/ datadir=/usr/local/mysql/data

12. 修改 mysql 目录权限

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

14. 添加开机启动
执行命令:
cp support-files/mysql.server /etc/init.d/mysql
把启动脚本放到开机初始化目录

15. 开启 mysql
service mysql start

配置文件 /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
来源:黑客派
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
浙公网安备 33010602011771号