ContOS7.4 + MySQL5.6.40安装

卸载自带MariaDB

[root@root tmp]# rpm -qa | grep mariadb
mariadb-libs-5.5.41-2.el7_0.x86_64
[root@root tmp]# rpm -e --nodeps mariadb-libs-5.5.41-2.el7_0.x86_64

下载安装包

下载MySQL RPM包

安装

// 下载
[root@root tmp]# wget https://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-5.6.40-1.el7.x86_64.rpm-bundle.tar
--2018-05-03 09:53:46--  https://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-5.6.40-1.el7.x86_64.rpm-bundle.tar
正在解析主机 dev.mysql.com (dev.mysql.com)... 137.254.60.11
正在连接 dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:https://cdn.mysql.com//Downloads/MySQL-5.6/MySQL-5.6.40-1.el7.x86_64.rpm-bundle.tar [跟随至新的 URL]
--2018-05-03 09:53:47--  https://cdn.mysql.com//Downloads/MySQL-5.6/MySQL-5.6.40-1.el7.x86_64.rpm-bundle.tar
正在解析主机 cdn.mysql.com (cdn.mysql.com)... 23.11.255.146
正在连接 cdn.mysql.com (cdn.mysql.com)|23.11.255.146|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:243456000 (232M) [application/x-tar]
正在保存至: “MySQL-5.6.40-1.el7.x86_64.rpm-bundle.tar”

100%[===========================================================================================================================================================>] 243,456,000 6.10MB/s 用时 41s

2018-05-03 09:54:29 (5.68 MB/s) - 已保存 “MySQL-5.6.40-1.el7.x86_64.rpm-bundle.tar” [243456000/243456000])

// 解压
[root@root tmp]# tar -xvf MySQL-5.6.40-1.el7.x86_64.rpm-bundle.tar
MySQL-shared-5.6.40-1.el7.x86_64.rpm
MySQL-devel-5.6.40-1.el7.x86_64.rpm
MySQL-server-5.6.40-1.el7.x86_64.rpm
MySQL-shared-compat-5.6.40-1.el7.x86_64.rpm
MySQL-test-5.6.40-1.el7.x86_64.rpm
MySQL-client-5.6.40-1.el7.x86_64.rpm
MySQL-embedded-5.6.40-1.el7.x86_64.rpm
// 安装,跳过此步操作,请先进行下一步操作,会出错
[root@root tmp]# rpm -ivh MySQL-server-5.6.40-1.el7.x86_64.rpm

出现错误:

警告:MySQL-server-5.6.40-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:MySQL-server-5.6.40-1.el7        ################################# [100%]
警告:用户mysql 不存在 - 使用root
警告:群组mysql 不存在 - 使用root
警告:用户mysql 不存在 - 使用root
警告:群组mysql 不存在 - 使用root
FATAL ERROR: please install the following Perl modules before executing /usr/bin/mysql_install_db:
Data::Dumper

解决方案:

// 安装组件
[root@root tmp]# yum install -y perl-Module-Install.noarch
// 卸载原有的,重新安装
[root@root tmp]# rpm -qa | grep -i mysql
MySQL-server-5.6.40-1.el7.x86_64
[root@root tmp]# rpm -e MySQL-server-5.6.40-1.el7.x86_64
警告:MySQL-server-5.6.40-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:MySQL-server-5.6.40-1.el7        ################################# [100%]
警告:用户mysql 不存在 - 使用root
警告:群组mysql 不存在 - 使用root
警告:用户mysql 不存在 - 使用root
警告:群组mysql 不存在 - 使用root
2018-05-03 10:26:04 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-03 10:26:04 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-05-03 10:26:04 0 [Note] /usr/sbin/mysqld (mysqld 5.6.40) starting as process 2589 ...
2018-05-03 10:26:04 2589 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-05-03 10:26:04 2589 [Note] InnoDB: The InnoDB memory heap is disabled
2018-05-03 10:26:04 2589 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-03 10:26:04 2589 [Note] InnoDB: Memory barrier is not used
2018-05-03 10:26:04 2589 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-03 10:26:04 2589 [Note] InnoDB: Using Linux native AIO
2018-05-03 10:26:04 2589 [Note] InnoDB: Using CPU crc32 instructions
2018-05-03 10:26:04 2589 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-05-03 10:26:04 2589 [Note] InnoDB: Completed initialization of buffer pool
2018-05-03 10:26:04 2589 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2018-05-03 10:26:04 2589 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2018-05-03 10:26:04 2589 [Note] InnoDB: Database physically writes the file full: wait...
2018-05-03 10:26:04 2589 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2018-05-03 10:26:05 2589 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2018-05-03 10:26:06 2589 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2018-05-03 10:26:06 2589 [Warning] InnoDB: New log files created, LSN=45781
2018-05-03 10:26:06 2589 [Note] InnoDB: Doublewrite buffer not found: creating new
2018-05-03 10:26:06 2589 [Note] InnoDB: Doublewrite buffer created
2018-05-03 10:26:06 2589 [Note] InnoDB: 128 rollback segment(s) are active.
2018-05-03 10:26:06 2589 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-05-03 10:26:06 2589 [Note] InnoDB: Foreign key constraint system tables created
2018-05-03 10:26:06 2589 [Note] InnoDB: Creating tablespace and datafile system tables.
2018-05-03 10:26:06 2589 [Note] InnoDB: Tablespace and datafile system tables created.
2018-05-03 10:26:06 2589 [Note] InnoDB: Waiting for purge to start
2018-05-03 10:26:06 2589 [Note] InnoDB: 5.6.40 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2018-05-03 10:26:06 2589 [Note] Binlog end
2018-05-03 10:26:06 2589 [Note] InnoDB: FTS optimize thread exiting.
2018-05-03 10:26:06 2589 [Note] InnoDB: Starting shutdown...
2018-05-03 10:26:08 2589 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2018-05-03 10:26:08 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-03 10:26:08 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-05-03 10:26:08 0 [Note] /usr/sbin/mysqld (mysqld 5.6.40) starting as process 2611 ...
2018-05-03 10:26:08 2611 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-05-03 10:26:08 2611 [Note] InnoDB: The InnoDB memory heap is disabled
2018-05-03 10:26:08 2611 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-03 10:26:08 2611 [Note] InnoDB: Memory barrier is not used
2018-05-03 10:26:08 2611 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-03 10:26:08 2611 [Note] InnoDB: Using Linux native AIO
2018-05-03 10:26:08 2611 [Note] InnoDB: Using CPU crc32 instructions
2018-05-03 10:26:08 2611 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-05-03 10:26:08 2611 [Note] InnoDB: Completed initialization of buffer pool
2018-05-03 10:26:08 2611 [Note] InnoDB: Highest supported file format is Barracuda.
2018-05-03 10:26:08 2611 [Note] InnoDB: 128 rollback segment(s) are active.
2018-05-03 10:26:08 2611 [Note] InnoDB: Waiting for purge to start
2018-05-03 10:26:08 2611 [Note] InnoDB: 5.6.40 started; log sequence number 1625977
2018-05-03 10:26:08 2611 [Note] Binlog end
2018-05-03 10:26:08 2611 [Note] InnoDB: FTS optimize thread exiting.
2018-05-03 10:26:08 2611 [Note] InnoDB: Starting shutdown...
2018-05-03 10:26:10 2611 [Note] InnoDB: Shutdown completed; log sequence number 1625987




A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
// 密码存放处
You will find that password in '/root/.mysql_secret'.

You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.

Also, the account for the anonymous user has been removed.

In addition, you can run:

  /usr/bin/mysql_secure_installation

which will also give you the option of removing the test database.
This is strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
[root@root tmp]# rpm -ivh MySQL-server-5.6.40-1.el7.x86_64.rpm
// 安装客户端
[root@root tmp]# rpm -ivh MySQL-client-5.6.40-1.el7.x86_64.rpm
// 安装开发环境
[root@root tmp]# rpm -ivh MySQL-devel-5.6.40-1.el7.x86_64.rpm

修改密码

使用此种RPM安装方式,直接查看 /root/.mysql_secret 获取初始密码,再进行修改

[root@root tmp]#  vim /root/.mysql_secret
# The random password set for the root user at Thu May  3 10:26:06 2018 (local time): PP5AHQi1LgirSWnu
[root@root tmp]# mysql -uroot -pPP5AHQi1LgirSWnu
Warning: Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@rabbit3 tmp]# systemctl restart mysql
[root@rabbit3 tmp]# mysql -uroot -pPP5AHQi1LgirSWnu
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.40

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> SET PASSWORD = PASSWORD('123456');

配置远程可登录

  • 授权法
mysql> grant all privileges  on *.* to root@'%' identified by "123456";
// 推送设置到内存或重启服务器也行
mysql> FLUSH PRIVILEGES;
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,185评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,445评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,684评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,564评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,681评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,874评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,025评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,761评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,217评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,545评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,694评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,351评论 4 332
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,988评论 3 315
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,778评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,007评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,427评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,580评论 2 349

推荐阅读更多精彩内容