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
正在解析主機(jī) dev.mysql.com (dev.mysql.com)... 137.254.60.11
正在連接 dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... 已連接牵啦。
已發(fā)出 HTTP 請(qǐng)求,正在等待回應(yīng)... 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
正在解析主機(jī) cdn.mysql.com (cdn.mysql.com)... 23.11.255.146
正在連接 cdn.mysql.com (cdn.mysql.com)|23.11.255.146|:443... 已連接摊腋。
已發(fā)出 HTTP 請(qǐng)求沸版,正在等待回應(yīng)... 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 用時(shí) 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
// 安裝,跳過此步操作兴蒸,請(qǐng)先進(jìn)行下一步操作视粮,會(huì)出錯(cuò)
[root@root tmp]# rpm -ivh MySQL-server-5.6.40-1.el7.x86_64.rpm

出現(xiàn)錯(cuò)誤:

警告:MySQL-server-5.6.40-1.el7.x86_64.rpm: 頭V3 DSA/SHA1 Signature, 密鑰 ID 5072e1f5: NOKEY
準(zhǔn)備中...                          ################################# [100%]
正在升級(jí)/安裝...
   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
準(zhǔn)備中...                          ################################# [100%]
正在升級(jí)/安裝...
   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
// 安裝開發(fā)環(huán)境
[root@root tmp]# rpm -ivh MySQL-devel-5.6.40-1.el7.x86_64.rpm

修改密碼

使用此種RPM安裝方式橙凳,直接查看 /root/.mysql_secret 獲取初始密碼蕾殴,再進(jìn)行修改

[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');

配置遠(yuǎn)程可登錄

  • 授權(quán)法
mysql> grant all privileges  on *.* to root@'%' identified by "123456";
// 推送設(shè)置到內(nèi)存或重啟服務(wù)器也行
mysql> FLUSH PRIVILEGES;
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市岛啸,隨后出現(xiàn)的幾起案子钓觉,更是在濱河造成了極大的恐慌,老刑警劉巖坚踩,帶你破解...
    沈念sama閱讀 206,214評(píng)論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件荡灾,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡瞬铸,警方通過查閱死者的電腦和手機(jī)批幌,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,307評(píng)論 2 382
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來嗓节,“玉大人荧缘,你說我怎么就攤上這事±剐” “怎么了截粗?”我有些...
    開封第一講書人閱讀 152,543評(píng)論 0 341
  • 文/不壞的土叔 我叫張陵,是天一觀的道長鸵隧。 經(jīng)常有香客問我桐愉,道長,這世上最難降的妖魔是什么掰派? 我笑而不...
    開封第一講書人閱讀 55,221評(píng)論 1 279
  • 正文 為了忘掉前任,我火速辦了婚禮左痢,結(jié)果婚禮上靡羡,老公的妹妹穿的比我還像新娘系洛。我一直安慰自己,他們只是感情好略步,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,224評(píng)論 5 371
  • 文/花漫 我一把揭開白布描扯。 她就那樣靜靜地躺著,像睡著了一般趟薄。 火紅的嫁衣襯著肌膚如雪绽诚。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,007評(píng)論 1 284
  • 那天杭煎,我揣著相機(jī)與錄音恩够,去河邊找鬼。 笑死羡铲,一個(gè)胖子當(dāng)著我的面吹牛蜂桶,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播也切,決...
    沈念sama閱讀 38,313評(píng)論 3 399
  • 文/蒼蘭香墨 我猛地睜開眼扑媚,長吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了雷恃?” 一聲冷哼從身側(cè)響起疆股,我...
    開封第一講書人閱讀 36,956評(píng)論 0 259
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎倒槐,沒想到半個(gè)月后旬痹,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 43,441評(píng)論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡导犹,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 35,925評(píng)論 2 323
  • 正文 我和宋清朗相戀三年唱凯,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片谎痢。...
    茶點(diǎn)故事閱讀 38,018評(píng)論 1 333
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡磕昼,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出节猿,到底是詐尸還是另有隱情票从,我是刑警寧澤,帶...
    沈念sama閱讀 33,685評(píng)論 4 322
  • 正文 年R本政府宣布滨嘱,位于F島的核電站峰鄙,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏太雨。R本人自食惡果不足惜吟榴,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,234評(píng)論 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望囊扳。 院中可真熱鬧吩翻,春花似錦兜看、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,240評(píng)論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至熊锭,卻和暖如春弧轧,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背碗殷。 一陣腳步聲響...
    開封第一講書人閱讀 31,464評(píng)論 1 261
  • 我被黑心中介騙來泰國打工精绎, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人亿扁。 一個(gè)月前我還...
    沈念sama閱讀 45,467評(píng)論 2 352
  • 正文 我出身青樓捺典,卻偏偏與公主長得像,于是被迫代替她去往敵國和親从祝。 傳聞我的和親對(duì)象是個(gè)殘疾皇子襟己,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,762評(píng)論 2 345

推薦閱讀更多精彩內(nèi)容