1、下载二进制安装包 mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
cd /usr/local/src
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
2、解压,创建用户
[root@8d83e8f22faa src]# tar -xzvf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
[root@8d83e8f22faa src]# ll
total 629300
drwxr-xr-x. 9 root root 129 Sep 4 13:41 mysql-5.7.23-linux-glibc2.12-x86_64
-rw-r--r--. 1 root root 644399365 Sep 4 13:38 mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
[root@8d83e8f22faa src]# mv mysql-5.7.23-linux-glibc2.12-x86_64 /usr/local/mysql
[root@8d83e8f22faa src]# cd /usr/local/mysql/
[root@8d83e8f22faa mysql]# ll
total 36
-rw-r--r--. 1 7161 31415 17987 Jun 8 17:56 COPYING
-rw-r--r--. 1 7161 31415 2478 Jun 8 17:56 README
drwxr-xr-x. 2 root root 4096 Sep 4 13:40 bin
drwxr-xr-x. 2 root root 55 Sep 4 13:41 docs
drwxr-xr-x. 3 root root 4096 Sep 4 13:39 include
drwxr-xr-x. 5 root root 230 Sep 4 13:41 lib
drwxr-xr-x. 4 root root 30 Sep 4 13:40 man
drwxr-xr-x. 28 root root 4096 Sep 4 13:41 share
drwxr-xr-x. 2 root root 90 Sep 4 13:41 support-files
[root@8d83e8f22faa mysql]# groupadd mysql //创建用户组mysql
[root@8d83e8f22faa mysql]# useradd -r -g mysql mysql //-r参数表示mysql用户是系统用户,不可用于登录系统,创建用户mysql并将其添加到用户组mysql中
[root@8d83e8f22faa mysql]# chown -R mysql ../mysql/
[root@8d83e8f22faa mysql]# chgrp -R mysql ../mysql/
3、创建配置文件
cat > /etc/my.cnf << EOF
[client]
port = 3306
socket = /var/lib/mysql/mysql.sock
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysql/mysqld.log
#pid-file=/var/run/mysqld/mysqld.pid --会有问题
pid-file=/usr/local/mysql/data/mysqld.pid
lower_case_table_names = 1 #不区分大小写
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
max_connections=5000
default-time_zone = '+8:00'
EOF
4、初始化数据库
[root@8d83e8f22faa mysql]# yum install libaio numactl
[root@8d83e8f22faa log]# touch mysqld.log
[root@8d83e8f22faa log]# chown -R mysql:mysql mysqld.log
[root@8d83e8f22faa log]# vi /root/.bash_profile #增加mysql的bin目录
PATH=/usr/local/mysql/bin:/data/mysql/lib:$PATH
export PATH
[root@8d83e8f22faa log]#
[root@8d83e8f22faa log]#
[root@8d83e8f22faa log]# source /root/.bash_profile
[root@8d83e8f22faa log]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --lc_messages_dir=/usr/local/mysql/share --lc_messagges=en_US
5、查看初始密码
[root@8d83e8f22faa log]# cat mysqld.log
2018-09-04T05:57:11.728815Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-09-04T05:57:13.354532Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-09-04T05:57:13.697469Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-09-04T05:57:13.765091Z 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: 5eddbeeb-b007-11e8-a05a-0242ac110002.
2018-09-04T05:57:13.768220Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-09-04T05:57:13.770678Z 1 [Note] A temporary password is generated for root@localhost: 5qP,dgGgD(zg
[root@8d83e8f22faa log]# mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[root@8d83e8f22faa tmp]# mkdir -p /var/lib/mysql
[root@8d83e8f22faa tmp]# chmod 777 /var/lib/mysql/
[root@8d83e8f22faa tmp]# chown -R mysql:mysql /var/lib/mysql/
[root@8d83e8f22faa tmp]# cd /var/run
[root@8d83e8f22faa run]# mkdir -p /var/run/mysqld
[root@8d83e8f22faa run]# chown -R mysql:mysql /var/run/mysqld
[root@8d83e8f22faa log]#
[root@8d83e8f22faa log]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@8d83e8f22faa log]#
[root@8d83e8f22faa log]#
[root@8d83e8f22faa log]# chkconfig --add mysqld
[root@8d83e8f22faa log]# chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@8d83e8f22faa log]#
[root@8d83e8f22faa log]#
[root@8d83e8f22faa log]# systemctl start mysqld
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
[root@8d83e8f22faa log]# systemctl status mysqld.service
â— mysqld.service - LSB: start and stop MySQL
Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2018-09-04 14:08:43 CST; 9s ago
Docs: man:systemd-sysv-generator(8)
Process: 328 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/FAILURE)
Sep 04 14:08:39 8d83e8f22faa systemd[1]: Starting LSB: start and stop MySQL...
Sep 04 14:08:43 8d83e8f22faa mysqld[328]: Starting MySQL... ERROR! The server quit without updating PID file (/var/run/mysqld/mysqld.pid).
Sep 04 14:08:43 8d83e8f22faa systemd[1]: mysqld.service: control process exited, code=exited status=1
Sep 04 14:08:43 8d83e8f22faa systemd[1]: Failed to start LSB: start and stop MySQL.
Sep 04 14:08:43 8d83e8f22faa systemd[1]: Unit mysqld.service entered failed state.
Sep 04 14:08:43 8d83e8f22faa systemd[1]: mysqld.service failed.
[root@8d83e8f22faa log]# cat mysqld.log
...
2018-09-04T06:08:40.929634Z 0 [ERROR] Could not create unix socket lock file /var/lib/mysql.sock.lock.
2018-09-04T06:08:40.929653Z 0 [ERROR] Unable to setup unix socket lock file.
2018-09-04T06:08:40.929661Z 0 [ERROR] Aborting
...
[root@8d83e8f22faa lib]# vi /etc/my.cnf
[root@8d83e8f22faa lib]# systemctl start mysqld
[root@8d83e8f22faa lib]# ps -ef | grep mysql
root 1579 1 0 14:18 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/var/run/mysqld/mysqld.pid
mysql 1827 1579 3 14:18 ? 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root 1857 32 0 14:18 ? 00:00:00 grep --color=auto mysql
[root@8d83e8f22faa lib]#
[root@8d83e8f22faa lib]#
[root@8d83e8f22faa lib]#
[root@8d83e8f22faa lib]#
6、启动服务,进入mysql,修改初始密码,运行远程连接(这里执行完后,密码将变成:abc123)
[root@8d83e8f22faa lib]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.23
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>
mysql>
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>
mysql>
mysql> SET PASSWORD = PASSWORD('abc123'); #重置密码
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> UPDATE `mysql`.`user` SET `Host` = '%', `User` = 'root' WHERE (`Host` = 'localhost') AND (`User` = 'root'); #设置允许root账号远程登录
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
[root@8d83e8f22faa lib]#
[root@8d83e8f22faa lib]#
[root@8d83e8f22faa lib]#
[root@8d83e8f22faa lib]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.23 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>
mysql>
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql>
mysql>
mysql>
mysql> quit
Bye
[root@8d83e8f22faa lib]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.2 netmask 255.255.0.0 broadcast 0.0.0.0
inet6 fe80::42:acff:fe11:2 prefixlen 64 scopeid 0x20<link>
ether 02:42:ac:11:00:02 txqueuelen 0 (Ethernet)
RX packets 11854 bytes 20197549 (19.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 7746 bytes 538027 (525.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 4 bytes 200 (200.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4 bytes 200 (200.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- Linux centos7环境下安装MySQL的步骤详解
Linux centos7环境下安装MySQL的步骤详解 安装MySQL mysql 有两个跟windows不同的地方 1).my.ini 保存到/etc/my.ini 2).用户权限,单独用户执行 ...
- Linux(CentOS7)下二进制安装MySQL5.7.26
记录一下自己在 CentOS7 下二进制安装 MySQL5.7.26 的过程,之前使用 Linux(CentOS7)下rpm安装MySQL8.0.16 之后发现 rpm 方式安装不利于维护,也不利于单 ...
- Ubuntu下安装MySQL 5.6.23
Ubuntu下安装MySQL 5.6.23 1.下载相应Linux-generic的源代码包.解压,将解压后的文件夹重命名为mysql.移动到/usr/local文件夹下: tar –xzf mysq ...
- 二进制安装MySQL数据库
今天安装的是二进制的mysql包5.7.21的包,在配置文件的时候采了好多坑,左后还是搞定了,来和大家分享一下 二进制msyql5.7.21版本的主从复制安装 新建/picclife目录 mkdir ...
- centos7.2下安装Mysql笔记
centos7.2下安装Mysql笔记 安装 MySQL 适用于 CentOS 7.0 或以后版本: yum install mariadb mariadb-server 适用于 CentOS 6.8 ...
- CentOS 6.5下二进制安装 MySQL 5.6
CentOS 6.5 二进制安装MySQL 5.6 1:查看系统版本 [root@10-4-5-9 mysql]# cat /etc/redhat-release CentOS release 6.5 ...
- 二进制安装MySQL及破解密码
二进制安装MySQL及破解密码 1.确保系统中有依赖的libaio 软件,如果没有: yum -y install libaio 2.解压二进制MySQL软件包 tar xf mysql-5.7.24 ...
- centos 7 安装MySQL 5.7.23
centos 7 安装MySQL 5.7.23 1. 上传MySQL安装包到服务器 mysql-5.7.23-linux-glibc2.5-x86_64.tar.gz 2. 解压MySQL安装 ...
- 在 Docker 的 CentOS7 镜像 中安装 mysql
在 Docker 的 CentOS7 镜像 中安装 mysql 本来以为是个很简单的过程居然折腾了这么久,之前部署云服务器时也没有好好地记录,因此记录下. 特别提醒:本文的操作环境是在 Docker ...
随机推荐
- 使用C语言简单模拟Linux的cat程序
先给出源码 //fileio.c #include<stdio.h> #include<stdlib.h> #include<fcntl.h> void print ...
- Power consumption comparison
Here is my draft evaluation when old MCU replacement for power consumption, the comparsion betwween ...
- try catch 用法实例
- day9大纲
01 作业内容回顾 函数的初识: 封装一个功能. def 函数名(): 函数体 函数的返回值:return 1,结束函数. 2,返回给执行者(函数名())值. return ----> None ...
- ML(5)——神经网络3(随机初始化与梯度检验)
随机初始化 在线性回归和逻辑回归中,使用梯度下降法之前,将θ设置为0向量,有时会习惯性的将神经网络中的权重全部初始化为0,然而这在神经网络中并不适用. 以简单的三层神经网络为例,将全部权重都设置为0, ...
- CSS如何实现”右部宽度固定,左部自适应“的布局
吃过晚饭后,开始刷前端笔试题,却遇到了一道CSS难题——使用CSS实现左部自适应.右部固定宽度为200px的布局.当时第一眼看到题目时,以为只是一道很简单的题目.不就是定义两个左浮动的div,右部的宽 ...
- 【转】Android AlertDialog自定义布局
原文网址:https://blog.csdn.net/u010694658/article/details/53022294 由于开发中经常使用弹框,然而系统自带的弹框太局限,也不太美观,经常不能满足 ...
- Golang 操作mysql使用举例---连接本地数据库
连接数据库的方式有两种:TCP和Unix域socket. 本文使用Unix domain sockets连接数据库.关于TCP连接数据库可以参考Go 操作mysql使用举例 下面例子中,演示了使用sh ...
- 用Shell判断字符串包含关系的方法小结
这篇文章主要给大家介绍了关于用Shell判断字符串包含关系的几种方法,其中包括利用grep查找.利用字符串运算符.利用通配符.利用case in 语句以及利用替换等方法,每个方法都给出了详细的示例代 ...
- Spark版本说明
Source code: Spark 源码,需要编译才能使用,另外 Scala 2.11 需要使用源码编译才可使用 Pre-build with user-provided Hadoop: &qu ...