下载
官网地址
根据自己环境选择,我这里选的是mysql-5.6.40 64位 Linux通用版本
下载后将文件上传到服务器,并赋予755可执行权限
安装
1、解压
[root@localhost soft]# tar -xvf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz
复制解压后的mysql目录
[root@localhost soft]# cp -r mysql-5.6.40-linux-glibc2.12-x86_64 /usr/local/mysql
2、添加用户组和用户
添加用户组
[root@localhost soft]# groupadd mysql
添加用户mysql且添加到用户组mysql
[root@localhost soft]# useradd -g mysql mysql
3、安装
安装前需要卸载系统自带的Mysql
- 检测系统是否安装:
[root@localhost soft]# rpm -qa | grep mysql
mysql-libs-5.1.73-5.el6_6.x86_64
- 检测到已安装,卸载之:
[root@localhost soft]# yum -y remove mysql-libs*
...
删除:
mysql-libs.x86_64 0:5.1.73-5.el6_6
作为依赖被删除:
cronie.x86_64 0:1.4.4-15.el6
cronie-anacron.x86_64 0:1.4.4-15.el6
crontabs.noarch 0:1.10-33.el6
postfix.x86_64 2:2.6.6-6.el6_5
redhat-lsb.x86_64 0:4.0-7.el6.centos
redhat-lsb-compat.x86_64 0:4.0-7.el6.centos
redhat-lsb-core.x86_64 0:4.0-7.el6.centos
redhat-lsb-graphics.x86_64 0:4.0-7.el6.centos
redhat-lsb-printing.x86_64 0:4.0-7.el6.centos
sysstat.x86_64 0:9.0.4-27.el6
完毕!
- 安装
[root@localhost soft]# cd /usr/local/mysql/
[root@localhost mysql]# mkdir ./data/mysql
[root@localhost mysql]# ll
总用量 68
drwxr-xr-x. 2 root root 4096 5月 31 20:07 bin
-rw-r--r--. 1 root root 17987 5月 31 20:06 COPYING
drwxr-xr-x. 4 root root 4096 5月 31 20:15 data
drwxr-xr-x. 2 root root 4096 5月 31 20:06 docs
drwxr-xr-x. 3 root root 4096 5月 31 20:06 include
drwxr-xr-x. 3 root root 4096 5月 31 20:06 lib
drwxr-xr-x. 4 root root 4096 5月 31 20:06 man
drwxr-xr-x. 10 root root 4096 5月 31 20:06 mysql-test
-rw-r--r--. 1 root root 2496 5月 31 20:06 README
drwxr-xr-x. 2 root root 4096 5月 31 20:06 scripts
drwxr-xr-x. 28 root root 4096 5月 31 20:06 share
drwxr-xr-x. 4 root root 4096 5月 31 20:06 sql-bench
drwxr-xr-x. 2 root root 4096 5月 31 20:06 support-files
[root@localhost mysql]# chown -R mysql:mysql ./
[root@localhost mysql]# ll
总用量 68
drwxr-xr-x. 2 mysql mysql 4096 5月 31 20:07 bin
-rw-r--r--. 1 mysql mysql 17987 5月 31 20:06 COPYING
drwxr-xr-x. 4 mysql mysql 4096 5月 31 20:15 data
drwxr-xr-x. 2 mysql mysql 4096 5月 31 20:06 docs
drwxr-xr-x. 3 mysql mysql 4096 5月 31 20:06 include
drwxr-xr-x. 3 mysql mysql 4096 5月 31 20:06 lib
drwxr-xr-x. 4 mysql mysql 4096 5月 31 20:06 man
drwxr-xr-x. 10 mysql mysql 4096 5月 31 20:06 mysql-test
-rw-r--r--. 1 mysql mysql 2496 5月 31 20:06 README
drwxr-xr-x. 2 mysql mysql 4096 5月 31 20:06 scripts
drwxr-xr-x. 28 mysql mysql 4096 5月 31 20:06 share
drwxr-xr-x. 4 mysql mysql 4096 5月 31 20:06 sql-bench
drwxr-xr-x. 2 mysql mysql 4096 5月 31 20:06 support-files
初始化mysql数据库
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# chmod 755 /etc/init.d/mysqld
[root@localhost mysql]# cp support-files/my-default.cnf /etc/my.cnf
修改启动脚本
[root@localhost mysql]# vi /etc/init.d/mysqld
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql
启动服务:
[root@localhost mysql]# service mysqld start
Starting MySQL.Logging to '/usr/local/mysql/data/mysql/localhost.err'.
.. SUCCESS!
测试连接
[root@localhost mysql]# bin/mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.40 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, 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>
配置环境变量
[root@localhost mysql]# vi /etc/profile
export PATH=$PATH:/usr/local/mysql/bin
[root@localhost mysql]# source /etc/profile
网友评论