系统平台:
CentOS release 7.4 (Final) 内核 3.10.0-693.el7.x86_64
https://dev.mysql.com/downloads/mysql/
在永胜等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站设计、做网站 网站设计制作按需设计,公司网站建设,企业网站建设,成都品牌网站建设,营销型网站建设,外贸营销网站建设,永胜网站建设费用合理。#getent group mysql > /dev/null || groupadd mysql
#getent passwd mysql > /dev/null || useradd -g mysql -r -s /sbin/nologin mysql
#tar xvf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
#cd /usr/local/
#ln -sv mysql-5.6.39-linux-glibc2.12-x86_64/ mysql
#chown -R mysql.mysql mysql/
#echo 'PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile.d/mysql.sh
检查文件
#cat /etc/profile.d/mysql.sh
加载环境变量文件 并检查
#source /etc/profile.d/mysql.sh
#echo $PATH
# mkdir -pv /data/mysqldb/3306/{logs,bin-logs,run,data}
# touch /data/mysqldb/3306/run/mysqld.pid
# touch /data/mysqldb/3306/logs/mysql-error.log
# chown -R mysql.mysql /data/mysqldb/ -R
# chmod -R 770 /data/mysqldb/
# chown -R mysql.mysql /data/mysqldb/
# chmod -R 770 /data/mysqldb
文件没有创建的话,启动Mysql时将会报错
#vim /etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set=utf8
[mysqld]
user = mysql
port = 3306
basedir=/usr/local/mysql
datadir = /data/mysqldb/3306/data
socket = /tmp/mysql.sock
log-bin = /data/mysqldb/3306/bin-logs/mysql-bin
binlog_format=mixed
symbolic-links=0
innodb_file_per_table = 1
skip_name_resolve = 1
slow_query_log = 1
long_query_time = 2
pid-file = /data/mysqldb/3306/run/mysqld.pid
log-error = /data/mysqldb/3306/logs/mysql-error.log
character-set-server=utf8
default-storage-engine=INNODB
[mysqld_safe]
# include all files from the config directory
#
!includedir /etc/my.cnf.d
# cd /usr/local/mysql
# bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysqldb/3306/data
使用二进制安装包里面的support-files/mysql.server这个启动脚本死活不能启动,报以下错误
Starting MySQL. ERROR! The server quit without updating PID file (/data/mysqldb/3306/run/mysqld.pid).
无奈之下,去mysql官网下载一个mysql的源码包,使用里面的mysql.server就没问题。呵呵。
#cp mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# chkconfig mysqld on
#chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
#service mysqld start
Starting MySQL. SUCCESS!
检查3306端口是否开启
#ss -ntl | grep 3306
LISTEN 0 50 *:3306 *:*
确认版本
# mysql -V
mysql Ver 14.14 Distrib 5.6.39, for linux-glibc2.12 (x86_64) using EditLine wrapper
#/usr/local/mysql/bin/mysql_secure_installation
按提示操作即可
#mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.6.39-log 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>
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。