三种方式安装mysql5.7

系统环境:centos7.2

yum安装

[root@MiWiFi-R1CL-srv~]#yum -y install mariadb-server

[root@MiWiFi-R1CL-srv~]#systemctl enable mariadb

[root@MiWiFi-R1CL-srv~]# systemctl start mariadb

[root@MiWiFi-R1CL-srv~]# systemctl status mariadb

[root@MiWiFi-R1CL-srv~]# mysql

Welcometo the MariaDB monitor.Commands endwith ; or \g.

YourMariaDB connection id is 3

Serverversion: 5.5.52-MariaDB MariaDB Server

Copyright(c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB[(none)]> show databases;

+--------------------+

|Database|

+--------------------+

|information_schema |

|mysql|

|performance_schema |

|test|

+--------------------+

4 rowsin set (0.00 sec)

卸载

[root@MiWiFi-R1CL-srv~]# systemctl stop mariadb

[root@MiWiFi-R1CL-srv~]# yum remove mariadb-server

二进制安装

下载地址:

https://dev.mysql.com/downloads/mysql

[root@MiWiFi-R1CL-srv~]# yum -y install libaiolibaio-devel

[root@MiWiFi-R1CL-srv~]# tar xf ./mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /usr/local

[root@MiWiFi-R1CL-srv~]# mv /usr/local/mysql-5.7.18-linux-glibc2.5-x86_64/ /usr/local/mysql

[root@MiWiFi-R1CL-srv

~]# vim /etc/my.cnf修改

[mysqld]

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

socket=/tmp/mysql.sock

[root@MiWiFi-R1CL-srv~]# cd /usr/local/mysql/

[root@MiWiFi-R1CL-srvmysql]#bin/mysqld--defaults-file=/etc/my.cnf --initialize --user=mysql--explicit_defaults_for_timestamp

2017-06-20T06:38:37.462412Z0 [Warning] InnoDB: New log files created, LSN=45790

2017-06-20T06:38:37.575081Z0 [Warning] InnoDB: Creating foreign key constraint system tables.

2017-06-20T06:38:37.643656Z0 [Warning] No existing UUID has been found, so we assume that this is thefirst time that this server has been started. Generating a new UUID:1733cadf-5583-11e7-bbb4-0800279d6a78.

2017-06-20T06:38:37.646871Z0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed'cannot be opened.

2017-06-20T06:38:37.647646Z

1 [Note]A temporary password is generated

for root@localhost: fss_j*HKl9Rt

[root@MiWiFi-R1CL-srvmysql]# support-files/mysql.server start

StartingMySQL. SUCCESS!

[root@MiWiFi-R1CL-srvmysql]# ./bin/mysql -uroot -p

Enter

password:随机密码

Welcometo the MySQL monitor.Commands end with; or \g.

YourMySQL connection id is 3

Serverversion: 5.7.18

Type'help;' or '\h' for help. Type '\c' to clear the current input statement.

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

QueryOK, 0 rows affected (0.02 sec)

安装时注意检查系统是否已经运行mysql其他版本及安装目录的权限

源码包安装

https://dev.mysql.com/downloads/mysql


MySQL从5.5开始,使用cmake进行编译设置;因此,我们需要安装cmake编译工具:

[root@MiWiFi-R1CL-srv~]#yum -y install cmake

从MySQL5.7版本开始,安装MySQL需要依赖Boost的C++扩展,而且只能是1.59.0版本;

Boost下载地址:http://www.boost.org/users/history;选择1.59.0版本下载,在编译是填写相应参数,指定Boost源码位置即可;

[root@MiWiFi-R1CL-srv~]# mkdir -p /usr/local/mysql/data

[root@MiWiFi-R1CL-srv~]# groupadd mysql

[root@MiWiFi-R1CL-srv~]# chown -R mysql:mysql/usr/local/mysql

[root@MiWiFi-R1CL-srv~]# mv ./boost_1_59_0 /usr/local/boost

--Could NOT find Curses (missing:CURSES_LIBRARY CURSES_INCLUDE_PATH)

CMakeError at cmake/readline.cmake:64 (MESSAGE):

Curses library not found.Please install appropriate package,

remove CMakeCache.txt and rerun cmake.OnDebian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it isncurses-devel.

[root@MiWiFi-R1CL-srvmysql-5.7.18]#rm -rf ./CMakeCache.txt&& yum -y install ncurses-devel

[root@MiWiFi-R1CL-srvmysql-5.7.18]# cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/usr/local/mysql/data-DMYSQL_UNIX_ADDR=/tmp/mysql.sock-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_BOOST=/usr/local/boost

[root@MiWiFi-R1CL-srvmysql-5.7.18]# make && make install

[root@MiWiFi-R1CL-srvmysql]#chown -R mysql:mysql/usr/local/mysql

[root@MiWiFi-R1CL-srvmysql]# cd /usr/local/mysql/

[root@MiWiFi-R1CL-srv~]# vim /etc/my.cnf修改

[mysqld]

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

socket=/tmp/mysql.sock

[root@MiWiFi-R1CL-srvmysql]# bin/mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql

--explicit_defaults_for_timestamp

2017-06-20T06:49:15.806202Z0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use--explicit_defaults_for_timestamp server option (see documentation for moredetails).

2017-06-20T06:49:16.136618Z0 [Warning] InnoDB: New log files created, LSN=45790

2017-06-20T06:49:16.207731Z0 [Warning] InnoDB: Creating foreign key constraint system tables.

2017-06-20T06:49:16.289767Z0 [Warning] No existing UUID has been found, so we assume that this is thefirst time that this server has been started. Generating a new UUID:93dd74c0-5584-11e7-bf81-08002746578c.

2017-06-20T06:49:16.292863Z0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed'cannot be opened.

2017-06-20T06:49:16.293407Z1 [Note] A temporary password is generated for root@localhost:3fuZI>kq>?7)

[root@MiWiFi-R1CL-srvmysql]# support-files/mysql.server start

StartingMySQL.2017-06-20T07:00:46.723634Z mysqld_safe error: log-error set to'/var/log/mariadb/mariadb.log', however file don't exists. Create writable foruser 'mysql'.

ERROR! The server quit without updating PIDfile (/usr/local/mysql/data/MiWiFi-R1CL-srv.pid).

删除配置文件中errlog

[root@MiWiFi-R1CL-srvmysql]# support-files/mysql.server start

StartingMySQL.Logging to '/usr/local/mysql/data/MiWiFi-R1CL-srv.err'.

SUCCESS!

[root@MiWiFi-R1CL-srvmysql]# ./bin/mysql -uroot -p

Enterpassword:

Welcometo the MySQL monitor.Commands end with; or \g.

YourMySQL connection id is 3

Serverversion: 5.7.18

Copyright(c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracleis 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>show databases;

ERROR1820 (HY000): You must reset your password using ALTER USER statement beforeexecuting this statement.

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

QueryOK, 0 rows affected (0.00 sec)

mysql>show databases;

+--------------------+

|Database|

+--------------------+

| information_schema|

|mysql|

|performance_schema |

|sys|

+--------------------+

4 rowsin set (0.00 sec)

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

推荐阅读更多精彩内容