MySQL下载地址与Centos7安装MySQL以及启动问题排查
启动问题(如The server quit without updating PID file)请查看最后的附录进行解决
一、MySQL国内镜像下载
- 网易:http://mirrors.163.com/mysql/
- 中科大:http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/
- 清华:https://mirrors.tuna.tsinghua.edu.cn/mysql/
二、国内镜像相关站点
只列取部分(其他相关软件可进入站点进行下载)
三、Centos7安装MySQL5.7
1. 下载并解压至/usr/local
镜像站下载(以版本mysql-5.7.31-linux-glibc2.12-x86_64为例)
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz
解压至/usr/local
tar -xvf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
重命名
cd /usr/local
mv mysql-5.7.31-linux-glibc2.12-x86_64/ mysql
2. 配置信息
新建my.cnf
mkdir -p /usr/local/mysql/etc
vi /usr/local/mysql/etc/my.cnf
在my.cnf中填入以下内容
[mysqld]
user=mysql
server-id=1
port = 3306
character_set_server=utf8mb4
datadir=/mnt/mysql/mysql_data
tmpdir=/mnt/mysql/mysql_tmp
# 日志
log-error=/mnt/mysql/log-error.txt
default-storage-engine=INNODB
join_buffer_size = 512M
tmp_table_size = 1G
max_allowed_packet = 64M
# 365
interactive_timeout = 31536000
# 24.86
wait_timeout = 2147483
read_buffer_size = 128M
read_rnd_buffer_size = 256M
sort_buffer_size = 256M
key_buffer_size=512M
back_log=500
flush_time=0
open_files_limit=4161
table_definition_cache=1400
binlog_row_event_max_size=16M
# 最大连接数
max_connections=1000
max_connect_errors = 1000
# 线程缓存大小
thread_cache_size=500
# 日志缓冲刷新的频繁程度
innodb_flush_log_at_trx_commit=2
innodb_buffer_pool_size=2G
innodb_log_file_size=512M
innodb_log_buffer_size=256M
innodb_thread_concurrency=32
innodb_autoextend_increment=64
innodb_buffer_pool_instances=8
innodb_concurrency_tickets=5000
innodb_old_blocks_time=1000
innodb_open_files=300
innodb_stats_on_metadata=0
innodb_file_per_table=1
innodb_checksum_algorithm=0
innodb_lock_wait_timeout = 50
# 瓶颈位
query_cache_size = 0
slow-query-log=1
long_query_time=10
lower_case_table_names=1
table_open_cache=4096
autocommit = 1
skip_name_resolve = 1
transaction_isolation = READ-COMMITTED
explicit_defaults_for_timestamp = 1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
注:
my.cnf配置文件的位置在:/usr/local/mysql/etc/
启动错误日志在:/mnt/mysql/log-error.txt
MySQL的wait_timeout连接已经修改为最大值,不会出现相关超时问题
3. 用户及用户组管理(提高安全)
新建组和用户
groupadd mysql
useradd -g mysql mysql -s /usr/sbin/nologin
创建数据目录(与my.cnf一致)
mkdir -p /mnt/mysql/mysql_data
mkdir -p /mnt/mysql/mysql_tmp
添加权限
chmod 644 /usr/local/mysql/etc/my.cnf
chmod 750 /mnt/mysql/mysql_data
chmod 750 /mnt/mysql/mysql_tmp
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /mnt/mysql/mysql_data
chown -R mysql:mysql /mnt/mysql/mysql_tmp
其他权限设置
touch /var/log/mariadb/mariadb.log
chown -R mysql:mysql /var/lib/mysql
chown -R mysql:mysql /var/log/mariadb/mariadb.log
4. 初始化数据库
进入目录
cd /usr/local/mysql/
初始化数据
./bin/mysqld --initialize
若有错误发生
message:error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
solution:yum -y install numactl.x86_64
message: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
solution:yum -y install libaio
5. 启动数据库
启动
/usr/local/mysql/support-files/mysql.server start
停止
/usr/local/mysql/support-files/mysql.server stop
重启
/usr/local/mysql/support-files/mysql.server restart
若启动有错误发生
如:The server quit without updating PID file (/mnt/mysql/mysql_data/xx.pid)!!首先查看启动错误日志信息:/mnt/mysql/log-error.txt
根据启动日志进行排查问题(直接百度一般都没啥用,切记根据日志进行定点查问题)
以及/var/log/mariadb/mariadb.log的日志
6. 默认密码修改
(1)先停止mysql服务
/usr/local/mysql/support-files/mysql.server stop
# 并查看进程,若有则kill
ps -ef|grep mysqld
结果如图所示

(2)启动 mysql 进入无需授权模式
./bin/mysqld --defaults-file=/usr/local/mysql/etc/my.cnf --skip-grant-tables --console
(3)新开一个窗口,并进入mysql目录下,执行以下命令连上数据库
./bin/mysql
(4)执行相关sql命令
-- 切换库
use mysql;
-- 更新密码为123456
update user set authentication_string=password("123456"),host = '%', password_expired='N' where user="root";
-- 查询结果
select user, authentication_string, host, password_expired from user;
FLUSH PRIVILEGES;
exit
7. 防火墙开放端口设置
开放端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
或者直接关闭防火墙(本地推荐)
# 启动
systemctl start firewalld
# 关闭
systemctl stop firewalld
# 查看状态
systemctl status firewalld
# 开机禁用
systemctl disable firewalld
# 开机启用
systemctl enable firewalld
附:启动问题排查
如:The server quit without updating PID file (/mnt/mysql/mysql_data/xx.pid)
!!首先查看启动错误日志信息:/mnt/mysql/log-error.txt
- 添加日志方法:
# 修改my.cnf配置文件,增加以下内容
log-error=/mnt/mysql/log-error.txt
- 同时对以下文件增加权限
touch /var/log/mariadb/mariadb.log
chown -R mysql:mysql /var/lib/mysql
chown -R mysql:mysql /var/log/mariadb/mariadb.log
然后根据启动日志进行排查问题(直接百度一般都没啥用,切记根据日志进行定点查问题)
或者/var/log/mariadb/mariadb.log的日志
若仍解决不了,可根据本文过程重新安装
重装MySQL过程数据库迁移注意点以及数据恢复,请看下篇内容!
MySQL下载地址与Centos7安装MySQL以及启动问题排查的更多相关文章
- linux mysql下载地址
linux mysql下载地址: https://dev.mysql.com/downloads/mysql/5.7.html#downloads
- CentOS7安装MYSQL。
参考这个文章(网页已存到本地):http://www.cnblogs.com/starof/p/4680083.html 安装完成后,本地登录MYSQL没有问题. 现在主要是在windows下用ora ...
- yum CentOS7安装mysql
配置阿里云yum源 [root@bogon ~]# cd /etc/yum.repos.d/ [root@bogon yum.repos.d]# mkdir repo_bak [root@bogon ...
- [CentOs7]安装mysql(2)
摘要 之前安装过一次mysql,最后配置,发现在本地无法连接,重启服务的时候一直卡在那里不动,感觉是安装的过程出问题,最后没办法还是卸载了,然后重新安装一下. [CentOs7]安装mysql Mys ...
- centos7安装mysql(yum)
centos7安装mysql(yum) ----安装环境----依赖安装----检查mysql是否已安装----安装----验证是否添加成功----选择要启用的mysql版本----通过Yum安装my ...
- centos7安装Mysql爬坑记录
centos7安装Mysql爬坑记录 查看是否已安装 使用下列命令查看是否已经安装过mysql/mariadb/PostgreSQL 如果未安装,不返回任何结果(ECS的centos镜像默认未安装 ...
- CentOS7 安装 MySQL Cluster 7.6.7
引用自:http://lemonlone.com/posts/mysql-ndb-cluster-install/ 仅做备份和配置文件更改 1.先在VMware中安装 CentOS-7-x86_64- ...
- Centos7 安装mysql服务器并开启远程访问功能
大二的暑假,波波老师送了一个华为云的服务器给我作测试用,这是我程序员生涯里第一次以root身份拥有一台真实的云服务器 而之前学习的linux知识在这时也派上了用场,自己的物理机用的是ubuntu系统, ...
- CentOS7安装mysql提示“No package mysql-server available.”
针对centos7安装mysql,提示"No package mysql-server available."错误,解决方法如下: Centos 7 comes with Mari ...
随机推荐
- jdbc编程学习之增删改查(2)
一,enum类型的使用 在SQL中没有布尔类型的数据,我们都使用过布尔类型,当属性的值只用两种情况时.例如性别等.那在数据库对这些属性的值个数比较少时我们应该使用什么数据类型呢?SQL给我们提供了枚举 ...
- spark集群运行模式
spark的集中运行模式 Local .Standalone.Yarn 关闭防火墙:systemctl stop firewalld.service 重启网络服务:systemctl restart ...
- 智能佳机械软手智能研究版 QB SOFTHAND Research
智能佳机械软手智能研究版是一种基于软机器人技术的拟人机器人手,灵活.适应性强,能够与周围环境.物体和人类进行交互,同时限制伤害操作员.破坏要处理的产品和破坏机器人本身的风险. 智能佳机械软手智 ...
- TurtleBot3 Waffle (tx2版华夫)(10)自主导航(A2激光雷达)
1)[Remote PC] 启动roscore $ roscore 2)[TurBot3] 启动turbot3 $ roslaunch turbot3_bringup minimal.launch 3 ...
- Elasticsearch java api操作(一)(Java Low Level Rest Client)
一.说明: 一.Elasticsearch提供了两个JAVA REST Client版本: 1.java low level rest client: 低级别的rest客户端,通过http与集群交互, ...
- wdcp 安装
lanmp一键安装包是wdlinux官网2010年开始推出的lamp,lnmp,lnamp(apache,nginx,php,mysql,zend,eAccelerator,pureftpd)应用环境 ...
- 关于ajax 异步文件上传 node 文件后台接口
<body> <img src="" alt="" id="img"> <input type="f ...
- Label_img&a
绝对路径 相对路径 从根目录开始写 从引用的文件所在目录开始写 也可以作为链接提示 target = _blank 新窗口打开 = _self 默认值 本窗口打开 = _new 新窗口打开 = _pa ...
- 关于 RNN 循环神经网络的反向传播求导
关于 RNN 循环神经网络的反向传播求导 本文是对 RNN 循环神经网络中的每一个神经元进行反向传播求导的数学推导过程,下面还使用 PyTorch 对导数公式进行编程求证. RNN 神经网络架构 一个 ...
- 自定义注解,更优雅的使用MP分页功能
分页功能使用 MP的分页功能是通过MyBatis的插件实现的,使用起来也非常简单.下面先介绍下使用方式. step1:配置分页插件 @Configuration @EnableTransactionM ...