三种方式安装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

三种方式安装mysql5.7_第1张图片

[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


三种方式安装mysql5.7_第2张图片

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.

[[email protected]]#rm -rf ./CMakeCache.txt&& yum -y install ncurses-devel

[[email protected]]# 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

[[email protected]]# 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)

你可能感兴趣的:(三种方式安装mysql5.7)