详解Linux中CentOS6.8下解压安装mysql-5.7.14
原文:http://blog.csdn.net/yangle4695/article/details/52185859
mysql下载地址:http://dev.mysql.com/downloads/mysql/#downloads
环境:centos6.8 32位
本教程安装MySQL是通过编译过的二进制文件进行安装。是不针对特定平台的通用安装方法,使用的二进制文件是后缀为.tar.gz的压缩文件
1、下载 http://dev.mysql.com/downloads/mysql/
2、解压缩到/usr/local/下面,mysql的主目录命名为mysql
[root@localhost local]# mkdir soft
[root@localhost local]# cd soft
[root@localhost soft]# tar zvxf mysql-5.7.14-linux-glibc2.5-i686.tar.gz -C /usr/local
[root@localhost soft]# cd ..
[root@localhost local]# mv mysql-5.7.14-linux-glibc2.5-i686/ mysql
3、在mysql下面创建data数据库文件目录
[root@localhost local]# mkdir mysql/data
4、创建mysql的用户组和用户,并对mysql目录设置用户组和用户
[root@localhost local]# groupadd mysql
[root@localhost local]# useradd mysql -g mysql
[root@localhost local]# cd mysql
[root@localhost mysql]# pwd
/usr/local/mysql
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .
5、初始化mysql并启动mysql服务
[root@localhost mysql]# cd /usr/local/mysql/bin
[root@localhost bin]# yum install libaio
已加载插件:fastestmirror, refresh-packagekit, security
设置安装进程
Loading mirror speeds from cached hostfile
* base: mirrors.opencas.cn
* extras: mirrors.btte.net
* updates: mirrors.btte.net
包 libaio-0.3.107-10.el6.i686 已安装并且是最新版本
无须任何处理
[root@localhost bin]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
2016-08-11 12:00:25 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2016-08-11 12:00:31 [WARNING] The bootstrap log isn't empty:
2016-08-11 12:00:31 [WARNING] 2016-01-09T04:00:29.262989Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2016-08-11T04:00:29.264643Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2016-08-11T04:00:29.264653Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
[root@localhost bin]# cd /usr/local/mysql/support-files
[root@localhost support-files]# ./mysql.server start
Starting MySQL. SUCCESS!
6、登录mysql,此版本最新版不许空密码登录,实际上有个初始化密码保存在/root/.mysql_secret这个文件里面,用这个密码第一次登录后,再修改密码。因此先cat查看下初始化密码(随机的,每次安装看到的密码都不一样):
[root@localhost support-files]# cat /root/.mysql_secret
# Password set for user 'root@localhost' at 2016-08-11 02:05:38
aeK>:/b,*Z+u
利用初始化密码aeK>:/b,*Z+u开始登录mysql:
[root@localhost ~]# cd /usr/local/mysql/bin
[root@localhost bin]# ./MySQL -uroot -p
password:aek>:/b,*Z+u
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.10
Copyright (c) 2000, 2015, 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>
显示登录成功,可以执行mysql命令操作了!
未配置的情况下每次登录需要进入bin目录下操作:
[root@localhost ~]# cd /usr/local/mysql/bin
[root@localhost bin]# ./mysql -uroot -p
7、 复制配置文件
[root@localhost mysql] cp support-files/my-medium.cnf /etc/my.cnf
8. 将mysqld服务加入开机自启动项。
*首先需要将scripts/mysql.server服务脚本复制到/etc/init.d/,并重命名为mysqld。
[root@localhostmysql] cp support-files/mysql.server /etc/init.d/mysqld
*通过chkconfig命令将mysqld服务加入到自启动服务项中。
[root@localhost mysql]#chkconfig --add mysqld
*注意服务名称mysqld就是我们将mysql.server复制到/etc/init.d/时重命名的名称。
*查看是否添加成功
[root@localhost mysql]#chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
9. 重启系统,mysqld就会自动启动了。
*检查是否启动
[root@localhost mysql]#netstat -anp|grep mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2365/mysqld
unix 2 [ ACC ] STREAM LISTENING 14396 2365/mysqld /tmp/mysql.sock
*如果不想重新启动,那可以直接手动启动。
[root@localhost mysql]#service mysqld start
Starting MySQL.. SUCCESS!
10 运行客户端程序mysql,在mysql/bin目录中,测试能否连接到mysqld。
[root@localhost mysql]#/usr/local/mysql/bin/mysql -uroot -p
password:
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 2
Server version:5.5.29-log MySQL Community Server (GPL)
Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of Oracle Corporation and/or its affiliates. Other names may betrademarks of their respective owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql> quit
Bye
*此时会出现mysql>命令提示符,可以输入sql语句,输入quit或exit退出。为了避免每次都输入mysql的全路径/usr/local/mysql/bin/mysql,可将其加入环境变量中,在/etc/profile最后加入两行命令:
- 方法一:
- 在/etc/profile文件中最后一行添加变量export PATH=$PATH:/usr/local/mysql/bin
【对所有用户生效(永久的)】 - 用VI在文件/etc/profile文件中增加变量,该变量将会对Linux下所有用户有效,并且是“永久的”。
- 要让刚才的修改马上生效,需要执行以下代码
- # source /etc/profile
- 方法二:
- 在用户目录下的.bash_profile文件中增加变量【对单一用户生效(永久的)】
- 用VI在用户目录下的.bash_profile文件中增加变量,改变量仅会对当前用户有效,并且是“永久的”。
- 要让刚才的修改马上生效,需要在用户目录下执行以下代码
- # source .bash_profile
- 方法三:
- 直接运行export命令定义变量【只对当前shell(BASH)有效(临时的)】
- 在shell的命令行下直接使用[export变量名=变量值]定义变量,该变量只在当前的shell(BASH)或其子shell(BASH)下是有效的,shell关闭了,变量也就失效了,再打开新shell时就没有这个变量,需要使用的话还需要重新定义。
- 例如:export PATH=$PATH:/usr/local/mysql/bin
这样就可以在shell中直接输入mysql命令来启动客户端程序了
[root@localhost mysql]#mysql -uroot -p
password:
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 3
Server version:5.5.29-log MySQL Community Server (GPL)
Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of Oracle Corporation and/or its
affiliates. Other namesmay be trademarks of their respective
owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql>
11、改mysql的root密码,新密码在此为'123456'
mysql> set password=password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)
12、设定远程登录mysql。在Linux下为了安全,默认是不允许mysql本机以外的机器访问mysql数据库服务,因此需要重新授权root。方便远程访问。
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> select Host,User from user;
+-----------+-----------+
| Host | User |
+-----------+-----------+
| % | root |
| localhost | mysql.sys |
| localhost | root |
+-----------+-----------+
3 rows in set (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO root@'%' identified by 'leizm';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
授权语句最后的‘leizm’是mysql数据库root用户的新密码。
13、非必要的步骤,如果远程连不上,估计是防火墙的问题,关闭试试:
[root@localhost mysql]# service iptables stop
setenforce 0iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:清除防火墙规则: [确定]
iptables:正在卸载模块: [确定]
[root@localhost mysql]# setenforce 0
setenforce: SELinux is disable
详解Linux中CentOS6.8下解压安装mysql-5.7.14的更多相关文章
- (转)详解Linux中SSH远程访问控制
详解Linux中SSH远程访问控制 原文:http://blog.51cto.com/dengqi/1260038 SSH:是一种安全通道协议,主要用来实现字符界面的远程登录,远程复制等功能(使用TC ...
- 详解Linux中的cat文本输出命令用法
作系统 > LINUX > 详解Linux中的cat文本输出命令用法 Linux命令手册 发布时间:2016-01-14 14:14:35 作者:张映 我要评论 这篇 ...
- win7下解压安装mysql的方法
在win7下通过解压安装mysql 5.7一直出现启动不成功,网上找了好久终于找到一个解决方法,记录一下: 1.解压下载的压缩包 2.在解压目录下,将my-default.ini改名为my.ini, ...
- Linux CentOS6.8下解压安装mysql-5.7.14完整介绍
环境:centos6.8 32位本教程安装MySQL是通过编译过的二进制文件进行安装.是不针对特定平台的通用安装方法,使用的二进制文件是后缀为.tar.gz的压缩文件1.下载 http://dev.m ...
- 详解linux中的ps命令
Linux中的ps命令是Process Status的缩写.ps命令用来列出系统中当前运行的那些进程.ps命令列出的是当前那些进程的快照,就是执行ps命令的那个时刻的那些进程,如果想要动态的显示进程信 ...
- 【转】命令行浏览器 curl 命令详解,Linux中访问url地址
CURL --- 命令行浏览器 这东西现在已经是苹果机上内置的命令行工具之一了,可见其魅力之一斑 1)二话不说,先从这里开始吧! curl http://www.yahoo.com 回车之后,www. ...
- 详解linux中install命令和cp命令的区别
基本上,在Makefile里会用到install,其他地方会用cp命令. 它们完成同样的任务——拷贝文件,它们之间的区别主要如下: .最重要的一点,如果目标文件存在,cp会先清空文件后往里写入新文件, ...
- 详解Linux交互式shell脚本中创建对话框实例教程_linux服务器
本教程我们通过实现来讲讲Linux交互式shell脚本中创建各种各样对话框,对话框在Linux中可以友好的提示操作者,感兴趣的朋友可以参考学习一下. 当你在终端环境下安装新的软件时,你可以经常看到信息 ...
- 详解Linux下iptables中的DNAT与SNAT设置(转)
详解Linux下iptables中的DNAT与SNAT设置 这篇文章主要介绍了Linux下iptables中的DNAT与SNAT设置,是Linux网络配置中的基础知识,需要的朋友可以参考下 原文连 ...
随机推荐
- Linux学习笔记:nohup & 后台任务
在linux中,使用nohup xxx.sh &可以将前台任务变成后台任务执行,如果只使用&的话,在突然断网或者关闭启动终端时,内核会向后台任务发送sighup信号,从而导致后台任务停 ...
- 20155225 2006-2007-2 《Java程序设计》第四周学习总结
20155225 2006-2007-2 <Java程序设计>第四周学习总结 教材学习内容总结 对"是一种"语法测试几次之后,总结一句:满足"是一种" ...
- spark集群安装[转]
[转]http://sofar.blog.51cto.com/353572/1352713 ====================================================== ...
- servlet 学习笔记(三)
同一用户的不同页面共享数据有以下四种方法: 1.sendRedirect()跳转 2.session技术 3.隐藏表单提交(form) 4. cookie技术(小甜饼) --------------- ...
- day5模块学习--random模块
Python中的random模块用于生成随机数 下面具体介绍random模块的功能: 1.random.random() #用于生成一个0到1的浮点数 随机浮点数:0<= n < ...
- 使用Merge存储引擎实现MySQL分表
一.使用场景 Merge表有点类似于视图.使用Merge存储引擎实现MySQL分表,这种方法比较适合那些没有事先考虑分表,随着数据的增多,已经出现了数据查询慢的情况. 这个时候如果要把已有的大数据量表 ...
- Git配置用户名密码
配置Git 在Linux下和windows下配置Git的方法差不多,只是在Linux下,可以在命令行里直接使用git config进行配置, 而在windows下则要先打开“Git Bash”,进入m ...
- 码云Android项目构建注意事项(转载)
1.ant项目 build.xml必须位于项目根目录. 2.maven项目 pom.xml必须位于项目根目录. 3.gradle项目 由于gradle的配置灵活,我们做了一些规范,并且增加了一下机制来 ...
- LAMP环境使用Composer安装Laravel
安装Composer 因为使用的Ubuntu服务器,所以我们使用apt安装: 1 $ sudo apt install composer 安装Laravel 首先创建一个项目目录,进入新目录使用Com ...
- MySQL性能优化之char、varchar、text的区别
参考来源:https://blog.csdn.net/brycegao321/article/details/78038272 在存储字符串时, 可以使用char.varchar或者text类型, 那 ...