MySQL8.0⼆进制包安装安装包下载
1.官⽅下载
这样就可以下载⼆进制包了
服务器中操作
1.删除之前安装的MySQL包
[root@localhost ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
[root@localhost ~]# yum erase -y mariadb-libs-5.5.60-1.el7_5.x86_64
2.解压缩
tar -xf mysql-8.0.13-linux-glibc2.12-x86_
3.重命名并移动到/usr/local/mysql
mv mysql-8.0.13-linux-glibc2.12-x86_64 /usr/local/mysql
4.创建mysql⽤户和组
groupadd mysql
useradd -r -g mysql -s /sbin/nologin mysql
5.创建数据⽬录,⽇志⽬录,配置⽂件⽬录,变更权限
mkdir /usr/local/mysql/data
mkdir /usr/local/mysql/etc
mkdir /usr/local/mysql/log
chown -R mysql:mysql /usr/local/mysql/
6.编辑mysql配置⽂件
vim /usr/local/mysql/etc/myf
[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
7.初始化数据库,并查看⽇志
cd /usr/local/mysql
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
tailf /usr/local/mysql/log/error.log
2019-01-13T20:27:49.270330+08:000 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.13) initializing of server in progress as process 6990
2019-01-13T20:27:53.320375+08:005 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: SV!sgk7?k0i=
2019-01-13T20:27:54.805257+08:000 [System] [MY-013170] [Server] /usr/local/mysql/bin/mysqld (m
ysqld 8.0.13) initializing of server has completed
记住这个临时密码,后边要⽤到
8.设置启动⽂件,设置环境变量
mysql下载后安装中出现提示不到安装包cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld
/etc/init.d/mysqld start
Starting MySQL.. SUCCESS!
[root@localhost ~]# ps -ef | grep mysql
root      70721020:30 pts/000:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/mysqld.pid
mysql      72877072720:30 pts/000:00:01 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/log/error.log --pid-file=/usr/local root      73346821020:30 pts/000:00:00 grep --color=auto mysql
配置环境变量
vim /etc/profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
source /etc/profile
9.登录并配置远程登录
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is8
Server version: 8.0.13
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> 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
这就⾏了

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。