MySQL 8.0二进制包安装
安装包下载
1.官方下载
服务器中操作
1.删除之前安装的MySQL包
[root@server02 etc]# rpm -qa | grep mariadb mariadb-libs-5.5.68-1.el7.x86_64 mariadb-devel-5.5.68-1.el7.x86_64 [root@server02 etc]# yum erase -y mariadb-libs-5.5.68-1.el7.x86_64
2.解压缩
[root@server02 ~]# tar xf mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz [root@server02 ~]# mv mysql-8.0.12-linux-glibc2.12-x86_64 /usr/local/mysql [root@server02 ~]# cd /usr/local/mysql/ [root@server02 mysql]# groupadd mysql [root@server02 mysql]# useradd -r -g mysql -s /sbin/nologin mysql [root@server02 mysql]# mkdir /usr/local/mysql/data [root@server02 mysql]# mkdir /usr/local/mysql/etc [root@server02 mysql]# mkdir /usr/local/mysql/log [root@server02 mysql]# chown -R mysql:mysql /usr/local/mysql/ [root@server02 mysql]# vim /usr/local/mysql/etc/my.cnf
3.编辑mysql配置文件
[root@server02 etc]# cat /usr/local/mysql/etc/my.cnf [mysql] port = 3306 socket = /usr/local/mysql/data/mysql.sock [mysqld] port = 3306 mysqlx_port = 33060 mysqlx_socket = /usr/local/mysql/data/mysqlx.sock basedir = /usr/local/mysql datadir = /usr/local/mysql/data socket = /usr/local/mysql/data/mysql.sock pid-file = /usr/local/mysql/data/mysqld.pid log-error = /usr/local/mysql/log/error.log #这个就是用之前的身份认证插件 default-authentication-plugin = mysql_native_password #保证日志的时间正确 log_timestamps = SYSTEM
4.初始化数据库,并查看日志
[root@server02 mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data [root@server02 mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld [root@server02 mysql]# /etc/init.d/mysqld start
切记要把/etc/my.cnf删除掉,要不然启动时会报错。 [root@server02 etc]# /etc/init.d/mysqld start Starting MySQL.... SUCCESS! [root@server02 ~]# tailf /usr/local/mysql/log/error.log 2020-12-29T01:02:05.915655Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release. 2020-12-29T09:02:05.916174+08:00 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.12) initializing of server in progress as process 8108 2020-12-29T09:02:18.045798+08:00 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: qr11AqDgis.d 2020-12-29T09:02:23.220369+08:00 0 [System] [MY-013170] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.12) initializing of server has completed
记住这个临时密码,后边要用到
5.配置环境变量
[root@server02 etc]# vim /etc/profile PATH=$PATH:$HOME/bin:/usr/local/mysql/bin [root@server02 etc]# source /etc/profile
6.登录并配置远程登录
[root@server02 etc]# source /etc/profile [root@server02 etc]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.12 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> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456!'; Query OK, 0 rows affected (0.02 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec) mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select host, user, authentication_string, plugin from user; +-----------+------------------+------------------------------------------------------------------------+-----------------------+ | host | user | authentication_string | plugin | +-----------+------------------+------------------------------------------------------------------------+-----------------------+ | localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | | localhost | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | | localhost | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | | localhost | root | *611725B3AA4055897CDB648E55E0A0EA856389E2 | mysql_native_password | +-----------+------------------+------------------------------------------------------------------------+-----------------------+ 4 rows in set (0.00 sec) #这里就可以看到root@localhost这里的密码已经是mysql_native_password方式了 #这就是创建一个远程用户登录 mysql> create user 'root'@'%' identified by '123456!'; Query OK, 0 rows affected (0.05 sec) mysql> grant all privileges on *.* to 'root'@'%' with grant option; Query OK, 0 rows affected (0.04 sec) mysql> select host, user, authentication_string, plugin from user; +-----------+------------------+------------------------------------------------------------------------+-----------------------+ | host | user | authentication_string | plugin | +-----------+------------------+------------------------------------------------------------------------+-----------------------+ | % | root | *43CAAB27D90B4E33EC75DEEFA02577F7E2BACE93 | mysql_native_password | | localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | | localhost | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | | localhost | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password | | localhost | root | *611725B3AA4055897CDB648E55E0A0EA856389E2 | mysql_native_password | +-----------+------------------+------------------------------------------------------------------------+-----------------------+ 5 rows in set (0.00 sec) mysql> exit Bye
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2019-12-29 解决虚拟机vmware虚拟机安装64位系统“此主机支持 Intel VT-x,但 Intel VT-x 处于禁用状态”的问题
2019-12-29 vmware虚拟机三种网络连接方式
2019-12-29 Docker Swarm简介