mysql 5.6.36源码安装_MySQL免编译安装及登录(5.6.36)

一、下载MySQL 5.6.36免编译安装包并上传至 /usr/local/src 目录(也可以使用wget命令直接下载至该目录)

二、解压缩

[root@JSH-01 src]# tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz

三、将解压缩后的文件移动至 /usr/local/ 目录下并改名为mysql

[root@JSH-01 src]# mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql

[root@JSH-01 local]# ls

aegis bin etc games include lib lib64 libexec mysql sbin share src

四、进入mysql目录

[root@JSH-01 local]# cd mysql

[root@JSH-01 mysql]# ls

bin COPYING data docs include lib man mysql-test README scripts share sql-bench support-files

五、创建mysql用户和SQL数据库存放目录

[root@JSH-01 mysql]# useradd mysql

[root@JSH-01 mysql]# mkdir /data

六、初始化安装MySQL并制定用户和目录,安装前需要先安装相关的依赖包。

[root@JSH-01 mysql]# yum install -y perl gcc kernel-devel

[root@JSH-01 mysql]# yum install -y autoconf

[root@JSH-01 mysql]# yum install -y libaio

[root@JSH-01 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql

执行完毕后输入命令 echo$? 回车看输出的结果是0还是1,如果是0则表示安装成功。或者看到两次 OK 也表示安装成功。

[root@JSH-01 mysql]# echo $?

0

七、拷贝配置文件和启动脚本

[root@JSH-01 mysql]# cp support-files/my-default.cnf /etc/my.cnf(拷贝配置文件并改名为 my.cnf )

cp: overwrite ‘/etc/my.cnf’? y

[root@JSH-01 mysql]# cp support-files/mysql.server /etc/init.d/mysqld(拷贝启动脚本并改名为 mysqld)

[root@JSH-01 mysql]# vi /etc/init.d/mysqld

拷贝完成之后编辑启动脚本mysqld并定义basedir 和 datadir

basedir=/usr/local/mysql

datadir=/data/mysql

八、保存完毕启动脚本后将其权限更改为 755(实际此文件默认权限就是 755)

[root@JSH-01 mysql]# ls -l /etc/init.d/mysqld 查看文件详细信息

-rwxr-xr-x 1 root root 10592 Nov 25 20:08 /etc/init.d/mysqld

九、设置MySQL开机启动

[root@JSH-01 mysql]# chkconfig --add mysqld

[root@JSH-01 mysql]# chkconfig --list

Note: This output shows SysV services only and does not include native

systemd services. SysV configuration data might be overridden by native

systemd configuration.

If you want to list systemd services use 'systemctl list-unit-files'.

To see services enabled on particular target use

'systemctl list-dependencies [target]'.

aegis 0:off 1:off 2:on 3:on 4:on 5:on 6:off

agentwatch 0:off 1:off 2:on 3:on 4:on 5:on 6:off

mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off

network 0:off 1:off 2:on 3:on 4:on 5:on 6:off

十、启动MySQL服务

[root@JSH-01 mysql]# service mysqld start

Starting MySQL.Logging to '/data/mysql/JSH-01.err'.

[ OK ]

[root@JSH-01 mysql]# netstat -lntp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3234/sshd

tcp6 0 0 :::3306 :::* LISTEN 22293/mysqld

由此可见MySQL使用的服务端口为3306

十一、如何停止MySQL服务

可以使用命令 killall mysqld 或者 service mysqld stop

十二、安装完之后如何登录MySQL ?

[root@JSH-01 ~]# mysql -uroot

-bash: mysql: 未找到命令

提示未找到是因为mysql命令路径为:/usr/local/mysql/bin/ 此时需要更改环境变量。编辑配置文件 vi /etc/profile 将export PATH=$PATH:/usr/local/mysql/bin/写入最后一行。

[root@JSH-01 ~]# echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

[root@JSH-01 ~]# export PATH=$PATH:/usr/local/mysql/bin/

[root@JSH-01 ~]# mysql -uroot

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.36 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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> quit;

Bye

[root@JSH-01 bin]# vi /etc/profile

[root@JSH-01 bin]# mysql -uroot

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.6.36 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值