https://downloads.mysql.com/archives/community/
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz
[root@localhost ~]# mkdir -p /home/mysql/program
[root@localhost ~]# tar xf /soft_resource/mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz -C /home/mysql/program/
[root@localhost ~]# ll /home/mysql/program/mysql-5.7.20-linux-glibc2.12-x86_64/
总用量 52
drwxr-xr-x 2 root root 4096 12月 11 23:38 bin
-rw-r--r-- 171613141517987 9月 13 23:48 COPYING
drwxr-xr-x 2 root root 4096 12月 11 23:39 docs
drwxr-xr-x 3 root root 4096 12月 11 23:38 include
drwxr-xr-x 5 root root 4096 12月 11 23:39 lib
drwxr-xr-x 4 root root 4096 12月 11 23:38 man
-rw-r--r-- 1716131415 2478 9月 13 23:48 README
drwxr-xr-x 28 root root 4096 12月 11 23:39 share
drwxr-xr-x 2 root root 4096 12月 11 23:39 support-files
各种文件夹的内容
● bin:包含客户端程序和mysqld等二进制可执行文件。
● docs:包含ChangeLog等信息。
● include:包含(头)文件的目录。
● lib:可动态加载的so库文件目录。
● man:包含man1、man8,可以利用这两个目录配置MySQL的帮助手册。
● share:包含MySQL初始化的一些SQL脚本以及错误代码、本地化语言文件等。
● support-files:包含单实例启停脚本mysql.server和多实例启停脚本mysqld_multi. server等。
# 创建mysql用户
[root@localhost ~]# useradd mysql -s /sbin/nologin
# 创建磁盘目录
[root@localhost ~]# mkdir -p /home/mysql/data/mysqldata1/{binlog,innodb_log,innodb_ts,log,mydata,relaylog,slowlog,sock,tmpdir,undo}
[root@localhost ~]# chown mysql.mysql /home/mysql/data -R
[root@localhost ~]# ln -s /home/mysql/program/mysql-5.7.20-linux-glibc2.12-x86_64 /usr/local/mysql
[root@localhost ~]# export PATH=$PATH:/usr/local/mysql/bin/
[root@localhost ~]# echo 'export PATH=$PATH:/usr/local/mysql/bin/' >> /etc/profile
[root@localhost ~]# mysqld --defaults-file=/etc/my.cnf --initialize-insecure
配置MySQL启停脚本(注意,这里是为了方便我们实验和学习,在生产环境中不建议配置自启动脚本)
[root@localhost ~]# cp -ar /usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld
[root@localhost ~]# chmod +x /etc/init.d/mysqld
[root@localhost ~]# chkconfig mysqld on
[root@localhost ~]# chkconfig --list mysqld
mysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
# 启动
[root@localhost ~]# service mysqld start
Starting MySQL.. [确定]
# 登录(由于初始化数据库时使用了--initialize-insecure选项,所以初始化完成之后没有密码,直接登录)
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.20-log 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>
至此,数据库快速安装完成。注意:在生产环境中还需要对数据库进行简单加固(例如:删除数据库中的匿名账号及其对应的权限,修改root密码等)。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。