博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux安装-mysql5.7.24
阅读量:5238 次
发布时间:2019-06-14

本文共 4312 字,大约阅读时间需要 14 分钟。

1、检查是否已安装过mariadb,若有便删除(linux系统自带的)

[root@localhost /]# rpm -qa | grep mariadb [root@localhost /]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64

2、检查是否已安装过mysql,若有便删除(linux系统自带的)

[root@localhost /]# rpm -qa | grep mysql [root@localhost /]# rpm -e –-nodeps mysql-libs-5.1.52.x86_64

3、检查mysql组和用户是否存在,如无创建:

  [root
@localhost ~]# cat /etc/group | grep mysql
  [root@localhost ~]# cat /etc/passwd |grep mysql
  [root@localhost ~]# groupadd mysql
  [root@localhost ~]# useradd -r -g mysql mysql

4、从官网下载mysql安装包,解压后移动到/usr/local/mysql下

[root@localhost download]# wget https:
//dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
[root@localhost download]# tar xzvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
[root@localhost download]# mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysql

5、在mysql下添加data目录

[root@localhost ~]# mkdir /usr/local/mysql/data

6、更改mysql目录下所有的目录及文件夹所属组合用户(一定不要少了 / ,之前就是这个原因搞了一天)

[root@localhost /]# cd /usr/local/ [root@localhost local]# chown -R mysql:mysql mysql/ [root@localhost local]# chmod -R 755 mysql/

7、编辑my.cnf,添加配置文件,配置内容为

[root@localhost local]# vi /usr/local/mysql/my.cnf

[client] 

#password=88888888 
socket=/usr/local/mysql/mysql.sock

[mysql]
socket=/usr/local/mysql/mysql.sock
# 设置mysql客户端默认字符集
default-character-set=utf8

[mysqld]

pid-file=/usr/local/mysql/mysqld.pid 
log-error = /usr/local/mysql/log/mysql-error.log 
#设置3306端口
port = 3306 
# 设置mysql的安装目录
basedir=/usr/local/mysql
# 设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql/data
#sock
socket=/usr/local/mysql/mysql.sock
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

#允许时间类型的数据为零(去掉NO_ZERO_IN_DATE,NO_ZERO_DATE)

sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
#ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

#解决mysql连接慢(201906181517)

skip-name-resolve

#skip-grant-tables ---------这行可以不加,慎重使用,

8、编译安装并初始化mysql,记住命令行末尾的密码:

[root@localhost local]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql 2017-08-31T08:50:23.910440Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-08-31T08:50:23.910635Z 0 [ERROR] Can't find error-message file '/usr/local/mysql/--datadir=/usr/local/mysql/data/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' con figuration directive.2017-08-31T08:50:24.709286Z 0 [Warning] InnoDB: New log files created, LSN=45790 2017-08-31T08:50:24.767540Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2017-08-31T08:50:24.892629Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 6e083b8f-8e29-11e7-88b1- 005056b427be.2017-08-31T08:50:24.895674Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2017-08-31T08:50:24.896645Z 1 [Note] A temporary password is generated for root@localhost: gFamcspKm2+u

9、启动mysql服务

 [root@localhost local]# /usr/local/mysql/support-files/mysql.server start

10、做个软连接,重启服务

[root@localhost local]# ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql [root@localhost local]# service mysql restart Shutting down MySQL.. SUCCESS! Starting MySQL. SUCCESS!

11、做个软链接,将安装目录下的mysql 放在/usr/bin 目录下

[root@localhost local]# ln -s /usr/local/mysql/bin/mysql /usr/bin

12、登录msyql,输入密码(密码为步骤7初始化生成的密码)

[root@localhost local]# mysql -u root -p Enter password:

13、修改密码并开放远程

msql>alter user 'root'@'localhost' identified by '123456';mysql>use mysql;msyql>update user set user.Host='%' where user.User='root';mysql>flush privileges;mysql>quit

14、设置开机自启动

1、将服务文件拷贝到init.d下,并重命名为mysql[root@localhost local]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld2、赋予可执行权限[root@localhost local]# chmod +x /etc/init.d/mysqld3、添加服务[root@localhost local]# chkconfig --add mysqld4、显示服务列表[root@localhost local]# chkconfig --list5、重启服务器(一般不用重启,所以此步略掉!!!)[root@localhost local]# reboot

转载于:https://www.cnblogs.com/iSun520/p/11151270.html

你可能感兴趣的文章
图片加载失败显示默认图片占位符
查看>>
【★】浅谈计算机与随机数
查看>>
解决 sublime text3 运行python文件无法input的问题
查看>>
javascript面相对象编程,封装与继承
查看>>
Atlas命名空间Sys.Data下控件介绍——DataColumn,DataRow和DataTable
查看>>
Java中正则表达式的使用
查看>>
算法之搜索篇
查看>>
新的开始
查看>>
java Facade模式
查看>>
NYOJ 120校园网络(有向图的强连通分量)(Kosaraju算法)
查看>>
Leetcode 226: Invert Binary Tree
查看>>
http站点转https站点教程
查看>>
解决miner.start() 返回null
查看>>
bzoj 2007: [Noi2010]海拔【最小割+dijskstra】
查看>>
BZOJ 1001--[BeiJing2006]狼抓兔子(最短路&对偶图)
查看>>
C# Dynamic通用反序列化Json类型并遍历属性比较
查看>>
128 Longest Consecutive Sequence 一个无序整数数组中找到最长连续序列
查看>>
定制jackson的自定义序列化(null值的处理)
查看>>
auth模块
查看>>
javascript keycode大全
查看>>