mysql5.7 二进制安装包安装

  • 下载二进制安装包(加速地址)
 wget  http://qiniudns.2fei.top/mysql/mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz


root@VM-0-3-ubuntu:~# cd /usr/local/
root@VM-0-3-ubuntu:/usr/local# wget  http://qiniudns.2fei.top/mysql/mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
安装准备

解压前 md5值校验

#官网5.7.25 MD5值
(mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz)    MD5: d241f5dd6527cf1f9ff39449538c1eb1 
#下载后校验
[root@VM_0_3_centos local]# md5sum mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
d241f5dd6527cf1f9ff39449538c1eb1  mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz

注意:
安装前检查 /etc/my.cnf or the /etc/mysql

*   If you have previously installed MySQL using your operating system native package management system, such as Yum or APT, you may experience problems installing using a native binary. Make sure your previous MySQL installation has been removed entirely (using your package management system), and that any additional files, such as old versions of your data files, have also been removed. You should also check for configuration files such as `/etc/my.cnf` or the `/etc/mysql` directory and delete them.

    For information about replacing third-party packages with official MySQL packages, see the related [APT guide](https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/) or [Yum guide](https://dev.mysql.com/doc/refman/5.7/en/replace-third-party-yum.html "2.5.2 Replacing a Third-Party Distribution of MySQL Using the MySQL Yum Repository").

*   MySQL has a dependency on the `libaio` library. Data directory initialization and subsequent server startup steps will fail if this library is not installed locally. If necessary, install it using the appropriate package manager. For example, on Yum-based systems:
  • 依赖
  • 5.7.19 以后 依赖 libnuma 库
#----------- 官网提供脚本---------------
#yum 方式
shell> yum search libaio 
shell> yum install libaio
#apt 方式
shell> apt-cache search libaio
shell> apt-get install libaio1
 
For MySQL 5.7.19 and later: Support for Non-Uniform Memory Access (NUMA) has been added to the generic Linux build, which has a dependency now on the libnuma library; if the library has not been installed on your system, use you system's package manager to search for and install it (see the preceding item for some sample commands).

SLES 11: As of MySQL 5.7.19, the Linux Generic tarball package format is EL6 instead of EL5. As a side effect, the MySQL client bin/mysql needs libtinfo.so.5.

开始安装(参考官网)

shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
#解压
shell> tar -zxvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
#软连接 (别名)
shell> ln -s mysql-5.7.25-linux-glibc2.12-x86_64 mysql
shell> cd mysql
shell> mkdir mysql-files
shell> chown mysql:mysql mysql-files
shell> chmod 750 mysql-files
#注意生成的临时密码  A temporary password is generated for root@localhost: mj)A.o%ey4n7
# 初始化不指定密码 bin/mysqld --initialize-insecure --user=mysql
shell> bin/mysqld --initialize --user=mysql 
#生成ssl
shell> bin/mysql_ssl_rsa_setup   
#   mysqld_safe 方式启动        
shell> bin/mysqld_safe --user=mysql &
# Next command is optional (可选 )
#
shell> cp support-files/mysql.server /etc/init.d/mysql.server
  • 添加环境变量
vim /etc/profile
# 追加path
export PATH=/usr/local/mysql/bin:$PATH
#重启
source /etc/profile
root@VM-0-3-ubuntu:/usr/local# source /etc/profile
  • 启动mysql(启动/重启/停止)
/etc/init.d/mysql.server start / restart / stop

root@VM-0-3-ubuntu:/usr/local# /etc/init.d/mysql.server start
[ ok ] Starting mysql.server (via systemctl): mysql.server.service.

#查看mysql 后台进程
root@VM-0-3-ubuntu:/usr/local# ps -ef|grep mysqld
root      9422     1  0 10:35 ?        00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/VM-0-3-ubuntu.pid
mysql     9521  9422  0 10:35 ?        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=VM-0-3-ubuntu.err --pid-file=/usr/local/mysql/data/VM-0-3-ubuntu.pid
root     10210  7484  0 10:40 pts/2    00:00:00 grep --color=auto mysqld
root@VM-0-3-ubuntu:/usr/local# 

  • 登陆mysql
--修改密码

mysql> set password=password('root');

--设置root账户的host地址(修改了才可以远程连接)

mysql>grant all privileges on *.* to 'root'@'%' identified by 'root';
mysql>flush privileges;

mysql root密码忘记了?

1. 挂维护页
2. 关数据库
root@VM-0-3-ubuntu:~# /etc/init.d/mysql.server stop
3. 跳过授权启动
root@VM-0-3-ubuntu:~# mysqld_safe --skip-grant-tables --skip-networking &
--skip-grant-tables : 连接层关闭验证模块,所有验证表不加载。
--skip-networking :连接层关闭TCP/IP协议,禁止远程访问。
4. 改密码
mysql> alter user root@'localhost' identified by '456';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql>
mysql>
mysql>
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> alter user root@'localhost' identified by '456';
Query OK, 0 rows affected (0.00 sec)
mysql>exit;
5.正常开启业务

关于初始化的新特性(5.6 和 5.7 )

5.6 版本的初始化程序:
/data/mysql/scripts/mysql_install_db --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data
初始化完成后:无密码和无安全策略的

5.7 版本的初始化程序:
(1)
/data/mysql/bin/mysqld --initialize --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data
(2)
/data/mysql/bin/mysqld --initialize-insecure  --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data

提示:5.7以后初始化命令变为bin/mysqld命令,提供了两种初始化方式
第一种初始化方式:开启临时密码和安全策略
第二种初始化方式和之前版本一样,是无密码无安全策略。
演示:

2019-04-03T03:40:15.595883Z 1 [Note] A temporary password is generated for root@localhost: **MWht)!4%sa,3**
安全策略?
密码的复杂度进行了要求,对于密码的过期时间设置了限制
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,544评论 6 501
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,430评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,764评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,193评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,216评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,182评论 1 299
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,063评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,917评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,329评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,543评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,722评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,425评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,019评论 3 326
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,671评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,825评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,729评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,614评论 2 353

推荐阅读更多精彩内容

  • 安装并配置MySQL数据库 3.2.1安装MySQL数据库 1.MySQL数据库的安装环境准备 如果读者没有物理服...
    SkTj阅读 4,041评论 0 6
  • feisky云计算、虚拟化与Linux技术笔记posts - 1014, comments - 298, trac...
    不排版阅读 3,844评论 0 5
  • 5.7和之前版本的MySQL有一些不同,现把CentOS 7下MySQL 5.7安装、配置与应用完整过程记下来,或...
    alterem阅读 540评论 0 0
  • 第一章:不被祝福的到来 午膳后,尹甜秦坐在小院子里的秋千上慢悠悠的荡着,秋千一上一下小幅度晃着,旁边年轻的小保姆小...
    落尽繁华似锦阅读 409评论 0 0
  • 今天的文章正好解决了我昨天的困惑。攻击性让人更具有魅力。这也是有时候我们为什么会觉得痞里痞气的男生特别帅,身上自带...
    我在灯火阑珊处阅读 545评论 1 3