阿里云服务器 Centos 7 安装mysql8.0.16

官网地址:https://dev.mysql.com/downloads/mysql/

一、mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar解压后有如下7个文件:

tar -xvf mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar
-rw-r--r-- 1 7155 31415  33432660 May  3 12:38 mysql-community-client-8.0.16-2.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415    588520 May  3 12:38 mysql-community-common-8.0.16-2.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   5712552 May  3 12:38 mysql-community-devel-8.0.16-2.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415  24493344 May  3 12:38 mysql-community-embedded-compat-8.0.16-2.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   3127296 May  3 12:38 mysql-community-libs-8.0.16-2.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415   2177156 May  3 12:38 mysql-community-libs-compat-8.0.16-2.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 422672748 May  3 12:39 mysql-community-server-8.0.16-2.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 114848996 May  3 12:40 mysql-community-test-8.0.16-2.el7.x86_64.rpm

二、安装顺序为:(建议装之前先把之前的mysql相关包全部卸载,rpm -e --nodeps <包名>即可)

rpm -ivh mysql-community-common-8.0.16-2.el7.x86_64.rpm

 warning: mysql-community-libs-8.0.16-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-libs-8.0.16-2.el7################################# [100%]

rpm -ivh mysql-community-libs-8.0.16-2.el7.x86_64.rpm

 warning: mysql-community-libs-8.0.16-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-libs-8.0.16-2.el7################################# [100%]

rpm -ivh mysql-community-libs-compat-8.0.16-2.el7.x86_64.rpm

 warning: mysql-community-libs-compat-8.0.16-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-libs-compat-8.0.1################################# [100%]

rpm -ivh mysql-community-client-8.0.16-2.el7.x86_64.rpm

warning: mysql-community-client-8.0.16-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-client-8.0.16-2.e################################# [100%] 

rpm -ivh mysql-community-server-8.0.16-2.el7.x86_64.rpm

warning: mysql-community-server-8.0.16-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-server-8.0.16-2.e################################# [100%]

yum install -y openssl-devel.x86_64 openssl.x86_64 

Installed:
  openssl-devel.x86_64 1:1.0.2k-16.el7_6.1                                                                                                                                                            

Dependency Installed:
  keyutils-libs-devel.x86_64 0:1.5.8-3.el7  krb5-devel.x86_64 0:1.15.1-37.el7_6  libcom_err-devel.x86_64 0:1.42.9-13.el7  libkadm5.x86_64 0:1.15.1-37.el7_6  libselinux-devel.x86_64 0:2.5-14.1.el7 
  libsepol-devel.x86_64 0:2.5-10.el7 

rpm -ivh mysql-community-devel-8.0.16-2.el7.x86_64.rpm

warning: mysql-community-devel-8.0.16-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-devel-8.0.16-2.el################################# [100%]

yum install -y perl.x86_64 perl-devel.x86_64 

Installed:
  perl-devel.x86_64 4:5.16.3-294.el7_6                                                                                                                                                                

Dependency Installed:
  gdbm-devel.x86_64 0:1.10-8.el7                    libdb-devel.x86_64 0:5.3.21-24.el7             perl-ExtUtils-Install.noarch 0:1.58-294.el7_6      perl-ExtUtils-MakeMaker.noarch 0:6.68-3.el7     
  perl-ExtUtils-Manifest.noarch 0:1.61-244.el7      perl-ExtUtils-ParseXS.noarch 1:3.18-3.el7      perl-Test-Harness.noarch 0:3.28-3.el7              pyparsing.noarch 0:1.5.6-9.el7                  
  systemtap-sdt-devel.x86_64 0:3.3-3.el7           

Complete!

yum install -y perl-JSON.noarch

Installed:
  perl-JSON.noarch 0:2.59-2.el7                                                                                                                                                                       

Complete!

yum -y install autoconf

Installed:
  autoconf.noarch 0:2.69-11.el7                                                                                                                                                                       

Dependency Installed:
  perl-Data-Dumper.x86_64 0:2.145-3.el7                                                                                                                                                               

Complete!

rpm -ivh mysql-community-test-8.0.16-2.el7.x86_64.rpm

warning: mysql-community-test-8.0.16-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-test-8.0.16-2.el7################################# [100%]

三、安装完毕后相关信息如下:

mysql -V

mysql  Ver 8.0.16 for Linux on x86_64 (MySQL Community Server - GPL)

配置文件的位置

ll /etc/my.cnf

-rw-r--r-- 1 root root 1243 May  3 05:11 /etc/my.cnf

四、初始化数据库

mysqld --initialize --console

五、目录授权,否则启动失败

chown -R mysql:mysql /var/lib/mysql/

六、启动msyql服务

systemctl start mysqld

备注:
  停止命令:service mysqld stop

七、查看msyql服务的状态

service mysqld status

● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-07-15 20:24:51 CST; 1min 18s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 13374 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 13397 (mysqld)
   Status: "SERVER_OPERATING"
   CGroup: /system.slice/mysqld.service
           └─13397 /usr/sbin/mysqld

Jul 15 20:24:49 iZbp109fnkszgzwbnmaoe1Z systemd[1]: Starting MySQL Server...
Jul 15 20:24:51 iZbp109fnkszgzwbnmaoe1Z systemd[1]: Started MySQL Server.


八、在/var/log/mysqld.log下查看临时密码

cat /var/log/mysqld.log

2019-07-15T12:23:06.493163Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.16) initializing of server in progress as process 13286
2019-07-15T12:23:10.070584Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: dK3rw_EM_mjs
2019-07-15T12:23:11.237915Z 0 [System] [MY-013170] [Server] /usr/sbin/mysqld (mysqld 8.0.16) initializing of server has completed
2019-07-15T12:24:05.782446Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.16) starting as process 13361
2019-07-15T12:24:05.793657Z 1 [ERROR] [MY-012271] [InnoDB] The innodb_system data file 'ibdata1' must be writable
2019-07-15T12:24:05.793678Z 1 [ERROR] [MY-012278] [InnoDB] The innodb_system data file 'ibdata1' must be writable
2019-07-15T12:24:05.793704Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2019-07-15T12:24:05.793814Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2019-07-15T12:24:05.793897Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-07-15T12:24:05.794672Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.16)  MySQL Community Server - GPL.
2019-07-15T12:24:50.367615Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.16) starting as process 13397
2019-07-15T12:24:50.979080Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2019-07-15T12:24:51.199081Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.16'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server - GPL.
2019-07-15T12:24:51.265716Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060

九、用临时密码登录到数据库

  • mysql -u root -p + 回车键
  • 输入临时密码(输入时不会显示出来,输入完直接回车)

十、执行下列mysql命令 修改密码

alter USER 'root'@'localhost' IDENTIFIED BY '新密码(必须包含:数字大小写字母特殊字符)';

十一、

依次执行下列mysql命令 授权远程连接

     查看所有用户是否可以远程连接,依次执行下列命令:

  • show databases;
  • use mysql;
  • select host, user, authentication_string, plugin from user;

    修改root用户host值,使root用户可以远程登录

  • update user set host = "%" where user='root';
  • 刷新
    flush privileges;

参考:

https://blog.csdn.net/qq_23167527/article/details/85236999

https://www.cnblogs.com/leohahah/p/9044904.html

转载于:https://my.oschina.net/summergao/blog/3076419

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值