1、准备工作

1.1 查询是否已安装MySQL相关配置,若安装移除,没安装忽略

[root@10 local]# yum list installed | grep mysql

[root@10 local]# yum -y remove mysql57-community-release.noarch

[root@10 local]# yum list installed | grep mysql

mysql57-community-release.noarch el7-8 installed

[root@10 local]# yum -y remove mysql57-community-release.noarch

1.2、查看centos版本 --不知道版本的可以使用相关命令查询下

cat /etc/redhat-release #查看CentOS版本

cat /proc/version

[root@10 /]# cat /etc/redhat-release

CentOS Linux release 7.6.1810 (Core)

[root@10 /]# cat /proc/version

Linux version 3.10.0-957.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Thu Nov 8 23:39:32 UTC 2018

2、安装MySQL

2.1、下载MySQL

2.2、安装MySQL源

[root@10 local]# yum localinstall mysql57-community-release-el7-8.noarch.rpm

根据提示 输入 Y

2.3、检查是否安装成功

[root@10 local]# yum repolist enabled | grep "mysql.-community."

[root@10 local]# yum repolist enabled | grep "mysql.*-community.*"

mysql-connectors-community/x86_64 MySQL Connectors Community 108

mysql-tools-community/x86_64 MySQL Tools Community 90

mysql57-community/x86_64 MySQL 5.7 Community Server 347

2.4 安装MySQL

[root@10 local]# yum install mysql-community-server

根据安装提示 Is this ok 输入 y

[root@10 local]# yum install mysql-community-server

。。。。。。此处省略。。。。。

事务概要

=================================================================================================================================================================================================================================================

安装 3 软件包 (+2 依赖软件包)

总下载量:194 M

Is this ok [y/d/N]: y

Downloading packages:

警告:/var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.26-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY ] 0.0 B/s | 67 kB --:--:-- ETA

mysql-community-common-5.7.26-1.el7.x86_64.rpm 的公钥尚未安装

(1/5): mysql-community-common-5.7.26-1.el7.x86_64.rpm | 274 kB 00:00:06

(2/5): mysql-community-libs-5.7.26-1.el7.x86_64.rpm | 2.2 MB 00:00:01

(3/5): mysql-community-libs-compat-5.7.26-1.el7.x86_64.rpm | 2.0 MB 00:00:00

(4/5): mysql-community-client-5.7.26-1.el7.x86_64.rpm | 24 MB 00:00:28

(5/5): mysql-community-server-5.7.26-1.el7.x86_64.rpm | 166 MB 00:00:41

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

总计 3.9 MB/s | 194 MB 00:00:49

从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 检索密钥

导入 GPG key 0x5072E1F5:

用户ID : "MySQL Release Engineering "

指纹 : a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5

软件包 : mysql57-community-release-el7-8.noarch (installed)

来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

是否继续?[y/N]:y

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

。。。。。。此处省略。。。。。

已安装:

mysql-community-libs.x86_64 0:5.7.26-1.el7 mysql-community-libs-compat.x86_64 0:5.7.26-1.el7 mysql-community-server.x86_64 0:5.7.26-1.el7

作为依赖被安装:

mysql-community-client.x86_64 0:5.7.26-1.el7 mysql-community-common.x86_64 0:5.7.26-1.el7

替代:

mariadb-libs.x86_64 1:5.5.60-1.el7_5

完毕!

[root@10 local]#

2.5 启动MySQL并查询启动状态

启动MySQL

[root@10 local]# systemctl start mysqld

查询启动状态

[root@10 local]# systemctl status mysqld

[root@10 local]# systemctl start mysqld

[root@10 local]# systemctl status mysqld

● mysqld.service - MySQL Server

Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)

Active: active (running) since 五 2019-05-31 10:01:34 CST; 1min 6s ago

Docs: man:mysqld(8)

http://dev.mysql.com/doc/refman/en/using-systemd.html

Process: 4539 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)

Process: 4466 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)

Main PID: 4542 (mysqld)

CGroup: /system.slice/mysqld.service

└─4542 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

5月 31 10:01:30 10.0.2.15 systemd[1]: Starting MySQL Server...

5月 31 10:01:34 10.0.2.15 systemd[1]: Started MySQL Server.

可以看到 服务已经正常启动

2.6 、 设置开机启动

[root@10 local]# systemctl enable mysqld

[root@10 local]# systemctl daemon-reload

[root@10 local]# systemctl enable mysqld

[root@10 local]# systemctl daemon-reload

2.7、MySQL修改root密码

MySQL安装完成之后 在var/log/mysqld.log 生成默认密码 ,可以使用cat命令查询密码

[root@10 local]# cat /var/log/mysqld.log

如下 密码位置 A temporary password is generated for root@localhost: Q+Cl2sDfnhOf

[root@10 local]# cat /var/log/mysqld.log

2019-05-31T02:01:30.489346Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2019-05-31T02:01:31.136488Z 0 [Warning] InnoDB: New log files created, LSN=45790

2019-05-31T02:01:31.258342Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2019-05-31T02:01:31.314779Z 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: 026dd721-8348-11e9-8b9f-0800272dc669.

2019-05-31T02:01:31.315398Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2019-05-31T02:01:31.315835Z 1 [Note] A temporary password is generated for root@localhost: Q+Cl2sDfnhOf

2019-05-31T02:01:34.105853Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2019-05-31T02:01:34.106981Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.26) starting as process 4542 ...

2019-05-31T02:01:34.121691Z 0 [Note] InnoDB: PUNCH HOLE support available

2019-05-31T02:01:34.121923Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2019-05-31T02:01:34.121963Z 0 [Note] InnoDB: Uses event mutexes

2019-05-31T02:01:34.121968Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier

2019-05-31T02:01:34.121972Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11

2019-05-31T02:01:34.121976Z 0 [Note] InnoDB: Using Linux native AIO

2019-05-31T02:01:34.122231Z 0 [Note] InnoDB: Number of pools: 1

2019-05-31T02:01:34.122313Z 0 [Note] InnoDB: Using CPU crc32 instructions

2019-05-31T02:01:34.123694Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M

2019-05-31T02:01:34.137848Z 0 [Note] InnoDB: Completed initialization of buffer pool

2019-05-31T02:01:34.140811Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().

2019-05-31T02:01:34.153257Z 0 [Note] InnoDB: Highest supported file format is Barracuda.

2019-05-31T02:01:34.159667Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables

2019-05-31T02:01:34.159740Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...

2019-05-31T02:01:34.280067Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.

2019-05-31T02:01:34.280872Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.

2019-05-31T02:01:34.280880Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.

2019-05-31T02:01:34.281002Z 0 [Note] InnoDB: Waiting for purge to start

2019-05-31T02:01:34.332651Z 0 [Note] InnoDB: 5.7.26 started; log sequence number 2525131

2019-05-31T02:01:34.333222Z 0 [Note] Plugin 'FEDERATED' is disabled.

2019-05-31T02:01:34.341944Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool

2019-05-31T02:01:34.344914Z 0 [Note] InnoDB: Buffer pool(s) load completed at 190531 10:01:34

2019-05-31T02:01:34.348719Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.

2019-05-31T02:01:34.349255Z 0 [Warning] CA certificate ca.pem is self signed.

2019-05-31T02:01:34.368394Z 0 [Note] Server hostname (bind-address): '*'; port: 3306

2019-05-31T02:01:34.368553Z 0 [Note] IPv6 is available.

2019-05-31T02:01:34.368563Z 0 [Note] - '::' resolves to '::';

2019-05-31T02:01:34.368581Z 0 [Note] Server socket created on IP: '::'.

2019-05-31T02:01:34.377423Z 0 [Note] Event Scheduler: Loaded 0 events

2019-05-31T02:01:34.377516Z 0 [Note] /usr/sbin/mysqld: ready for connections.

Version: '5.7.26' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL)

也可以使用命名直接查询文件查找root 密码所在行

[root@10 local]# grep 'temporary password' /var/log/mysqld.log

[root@10 local]# grep 'temporary password' /var/log/mysqld.log

2019-05-31T02:01:31.315835Z 1 [Note] A temporary password is generated for root@localhost: Q+Cl2sDfnhOf

PS 密码就是 Q+Cl2sDfnhOf

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password01!';

注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678';

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password01!';

Query OK, 0 rows affected (0.00 sec)

2.8、添加远程登录用户

默认只允许root帐户在本地登录,如果要在其它机器上连接mysql,必须修改root允许远程连接,或者添加一个允许远程连接的帐户

添加用户 test 密码Testuser01!

GRANT ALL PRIVILEGES ON . TO 'test'@'%' IDENTIFIED BY 'Testuser01!' WITH GRANT OPTION;

mysql> GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' IDENTIFIED BY 'Testuser01!' WITH GRANT OPTION;

Query OK, 0 rows affected, 1 warning (0.00 sec)

2.9、MySQL通过改配置设置区分大小写 --- 不要试了 反正我没有成功

不知道为什么 我这儿安装 MySQL居然不区分大小写。。。

只能自己设置了 先退出 MySQL界面

mysql> exit

进入配置编辑 vim /etc/my.cnf

[root@10 local]# vim /etc/my.cnf

输入 i 进入编辑模式 编辑完成后 按esc 退出编辑模式,输入 :wq 保存退出

#解决中文乱码问题

character_set_server=utf8

#设置字段值区分大小写、

collation_server=utf8_bin

#设置表名不区分大小写(0:敏感)

lower_case_table_names=1

image.png

MySQL重启

[root@10 local]# systemctl restart mysqld

2.10、MySQL建表时设置区分大小写 通过 BINARY 字段

DROP TABLE IF EXISTS su_user;

CREATE TABLE su_user (

user_id varchar(6) NOT NULL COMMENT '用户ID',

login_name varchar(10) BINARY NOT NULL COMMENT '登录名'

modifyTime datetime NOT NULL COMMENT '操作时间',

PRIMARY KEY (user_id),

KEY FK_user_organ (org_id),

CONSTRAINT FK_user_organ FOREIGN KEY (org_id) REFERENCES dt_organ (id)

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

2.10、MySQL查询时设置区分大小写 通过 BINARY 字段

SELECT * FROM su_user WHERE BINARY login_name = 'admin'

-----end---

centos mysql 大小写_linux 、centos 安装MySQL及踩坑大小写敏感相关推荐

  1. linux下mysql案例_Linux下安装MySQL多实例

    环境说明: Centos 6.6 64位 mysql 使用最新版本5.7.16版本 这里安装两个MySQL实例,分别使用3306/3307端口号 目录结构: /data/mysql/mysql3306 ...

  2. linux安装自带mysql吗_Linux下安装mysql

    前提下必须要有这三个文件夹 A.jpg B.jpg 还要安装这两个软件:直接百度官网即可: 先通过Xftp6这个软件,编译文件夹, C.jpg 搭建mysql 1.查看CentOS自带的mysql r ...

  3. linux 用root安装mysql数据库_Linux上安装Mysql及简单的使用详解

    1. 安装mysql sudo apt-get update sudo apt-get install mysql-server sudo apt-get install python-mysqldb ...

  4. linux php 安装mysql数据库_linux php安装mysql数据库有哪些方法

    linux php安装mysql数据库有哪些方法 发布时间:2020-07-15 15:25:56 来源:亿速云 阅读:74 作者:Leah 本篇文章给大家分享的是有关linux php安装mysql ...

  5. 安装mysql冲突_Linux下安装mysql版本冲突问题解决

    由于在使用的linux服务器上已经安装了一个较低版本的mysql server,使用rpm包进行安装时,提示版本冲突,安装不能继续进行. 由于旧的数据不想要了,解决办法是这样的: 1. 先把系统里安装 ...

  6. linux mysql 移动_Linux下安装MySQL

    1.安装前需要检查下机器是否已经安装过MySQL: rpm -qa |grep mysql 如果安装过需要卸载:rpm -e mysql// 普通删除模式 rpm -e --nodeps mysql/ ...

  7. mysql linux 手动安装mysql服务_Linux手动安装Mysql

    以下是摘自mysql官方文档中关于手动安装MySQL 二进制分发版的说明: 一:安装 必须执行以便安装并使用MySQL 二进制分发版的基本命令是: shell groupadd mysql shell ...

  8. linux的mysql本地yum安装_Linux Centos 下使用yum 命令安装mysql实现步骤

    Linux Centos 下使用yum 命令安装mysql实现步骤 1. 查看服务器中有没有安装过Mysql 1. 查看有没有安装包: yum list mysql* #移除已经安装的mysql yu ...

  9. 使用yum命令安装mysql_Linux Centos 下使用yum 命令安装mysql实现步骤

    linux centos 下使用yum 命令安装mysql实现步骤 1. 查看服务器中有没有安装过mysql 1. 查看有没有安装包: yum list mysql* #移除已经安装的mysql yu ...

最新文章

  1. 西部数码买哪处线路的云服务器,云服务器买哪个区合适
  2. nagios监控haproxy(借助脚本)
  3. python打包成exe闪退_脚本程序打包后,黑框一闪而过,程序不能运行
  4. iOS自动化探索(四)自动化测试框架pytest - 安装和使用
  5. Java为什么会存成undefined,为什么我在Java中获得NoClassDefFoundError?
  6. 在Linux内核使用Kasan
  7. 重写慢日志解析程序,实现打印慢SQL信息及其所属数据库
  8. 【Nginx】第一章 快速入门
  9. Flash上传组件之SWFUpload文件上传
  10. ggplot2作图详解:主题(theme)设置
  11. Springboot中拦截器的使用
  12. 单片机基础:MCS-51单片机的硬件结构(附硬件结构框图)
  13. mysql 大文本_MySQL长文本存储类型
  14. “前首富”牟其中:欠的人情太多,要留着命来还
  15. 4000元台式电脑组装配置单2022 4000元组装电脑配置清单
  16. tx:advice标签
  17. CSDN文章转onenote笔记(markdown)
  18. jenkins + svn + maven +svn 实现当SVN提交代码后自动触发打包部署
  19. 四阶龙格库塔法的基本思想_利用龙格库塔法求解郎之万方程.doc
  20. 无线网卡m2 ngff keyakeye接口改转多口有线网卡实现软路由

热门文章

  1. 构建新型现代化智慧博物馆之物联网环境监控方案
  2. 高通平台耳机类型识别
  3. 关于tensor的shape理解
  4. STM32F103C8T6实现LED闪烁
  5. 3.9 编写程序,模拟石头剪刀布游戏。程序随机产生一个数,这个数为2、1或0,分别表示石头剪刀和布。
  6. MAC下微信双开(一键命令)
  7. ContextCapture User Guide V4.4.11 Welcome(Smart3D 帮助文档 第一章 欢迎)
  8. 用什么软件测试电视盒子真假,几十款电视盒子软件,只挑出6款神作,可消除一切看视频的阻碍!...
  9. 加速更新DNS解析记录的方法
  10. java文件 默认打开方式_修改文件的默认打开方式(亲测有效)