Linux【CentOS6.4】普通用户安装Mysql-8.0.26版本数据库

1、从MysqL官网下载mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz

在这里插入图片描述


2、进入Linux系统进行安装

(1)、把下载好的mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz放入/home/app/common目录下

[app@localhost common]$ pwd
/home/app/common
[app@localhost common]$ ll
total 893372
-rw-------. 1 app app 914806904 Jan 10 11:19 MysqL-8.0.26-linux-glibc2.12-x86_64.tar.xz
[app@localhost common]$

(2)、解压文件

[app@localhost common]$ tar -xvf MysqL-8.0.26-linux-glibc2.12-x86_64.tar.xz
[app@localhost common]$ ll
total 893376
drwx------. 9 app app      4096 Jan 19 09:46 MysqL-8.0.26-linux-glibc2.12-x86_64
-rw-------. 1 app app 914806904 Jan 10 11:19 MysqL-8.0.26-linux-glibc2.12-x86_64.tar.xz

(3)、剪切到其他目录

[app@localhost common]$ mv MysqL-8.0.26-linux-glibc2.12-x86_64 /uploaddir/MysqL-8.0.26-8080
[app@localhost common]$ cd /uploaddir/
[app@localhost uploaddir]$ ll
total 20
drwx------.  2 app app 4096 Dec 18  2019 20191218_90
drwx------. 13 app app 4096 Jan 13 15:47 MysqL-8.0.26
drwx------.  9 app app 4096 Jan 19 09:46 MysqL-8.0.26-8080
drwxrwxr-x.  6 app app 4096 Jul 30  2018 ueditor
drwxrwxr-x. 20 app app 4096 Dec 16 16:51 uploadfiles

(4)、进入mysql-8.0.26-8080目录创建tmp/log目录

[app@localhost uploaddir]$ cd MysqL-8.0.26-8080
[app@localhost MysqL-8.0.26-8080]$ ll
total 304
drwx------.  2 app app   4096 Jul  1  2021 bin
drwx------.  2 app app   4096 Jul  1  2021 docs
drwx------.  3 app app   4096 Jul  1  2021 include
drwx------.  6 app app   4096 Jul  1  2021 lib
-rw-------.  1 app app 276551 Jul  1  2021 LICENSE
drwx------.  4 app app   4096 Jul  1  2021 man
-rw-------.  1 app app    666 Jul  1  2021 README
drwx------. 28 app app   4096 Jul  1  2021 share
drwx------.  2 app app   4096 Jul  1  2021 support-files
[app@localhost MysqL-8.0.26-8080]$ mkdir tmp
[app@localhost MysqL-8.0.26-8080]$ mkdir log
[app@localhost MysqL-8.0.26-8080]$ ll
total 312
drwx------.  2 app app   4096 Jul  1  2021 bin
drwx------.  2 app app   4096 Jul  1  2021 docs
drwx------.  3 app app   4096 Jul  1  2021 include
drwx------.  6 app app   4096 Jul  1  2021 lib
-rw-------.  1 app app 276551 Jul  1  2021 LICENSE
drwx------.  2 app app   4096 Jan 19 11:08 log
drwx------.  4 app app   4096 Jul  1  2021 man
-rw-------.  1 app app    666 Jul  1  2021 README
drwx------. 28 app app   4096 Jul  1  2021 share
drwx------.  2 app app   4096 Jul  1  2021 support-files
drwx------.  2 app app   4096 Jan 19 11:08 tmp

(5)、创建并配置my.cnf文件【重点!!!】

[app@localhost MysqL-8.0.26-8080]$ touch my.cnf
[app@localhost MysqL-8.0.26-8080]$ ll
total 304
drwx------.  2 app app   4096 Jul  1  2021 bin
drwx------.  2 app app   4096 Jul  1  2021 docs
drwx------.  3 app app   4096 Jul  1  2021 include
drwx------.  6 app app   4096 Jul  1  2021 lib
-rw-------.  1 app app 276551 Jul  1  2021 LICENSE
drwx------.  4 app app   4096 Jul  1  2021 man
-rw-------.  1 app app      0 Jan 19 13:35 my.cnf
-rw-------.  1 app app    666 Jul  1  2021 README
drwx------. 28 app app   4096 Jul  1  2021 share
drwx------.  2 app app   4096 Jul  1  2021 support-files
[app@localhost MysqL-8.0.26-8080]$ vim my.cnf

[client]
# 服务端口---因为服务器上已有数据库3306已被占用,所以我这边设置的端口号为8080
port = 8080
# 指定套接文件
socket = /uploaddir/MysqL-8.0.26-8080/tmp/MysqL.sock

[MysqLd]
# 服务端口---因为服务器上已有数据库3306已被占用,所以我这边设置的端口号为8080
port = 8080
# 数据目录
datadir = /uploaddir/MysqL-8.0.26-8080/data
# 指定pid文件
pid-file = /uploaddir/MysqL-8.0.26-8080/tmp/MysqL.pid
# 指定套接文件
socket = /uploaddir/MysqL-8.0.26-8080/tmp/MysqL.sock
# 指定错误日志
log_error = /uploaddir/MysqL-8.0.26-8080/log/MysqLd.log
# 表示表名存储在磁盘是小写的,但是比较的时候是不区分大小写
lower_case_table_names = 1
# 表示跳过数据库权限验证
skip-grant-tables
# 表示打开日志
slow_query_log = ON
# 表示慢查询日志										
slow_query_log_file = /uploaddir/MysqL-8.0.26-8080/log/slow-queries.log
# 表示查询超过两秒才记录
long_query_time = 10
# 表示记录下没有使用索引的查询
#log-queries-not-using-indexes
# 表示语法校验规则												
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

(6)、进入mysql-8.0.26-8080/bin目录进行初始化

[app@localhost MysqL-8.0.26-8080]$ cd bin
[app@localhost bin]$ ./MysqLd --defaults-file=/uploaddir/MysqL-8.0.26-8080/my.cnf --user=app --basedir=/uploaddir/MysqL-8.0.26-8080 --datadir=/uploaddir/MysqL-8.0.26-8080/data  --initialize --lower-case-table-names=1

(7)、启动服务

[app@localhost bin]$ ./MysqLd_safe --defaults-file=/uploaddir/MysqL-8.0.26-8080/my.cnf --user=app &

查看进程是否启动成功

[app@localhost bin]$ ps -ef|grep MysqL

在这里插入图片描述


(8)、登录本地服务

[app@localhost bin]$ ./MysqL -S /uploaddir/MysqL-8.0.26-8080/tmp/MysqL.sock -uroot -p
Enter password: 直接回车,因为my.cnf配置了跳过数据库权限验证
Welcome to the MysqL monitor.  Commands end with ; or \g.
Your MysqL connection id is 7
Server version: 8.0.26 MysqL Community Server - GPL

copyright (c) 2000, 2021, Oracle and/or its affiliates.

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> 

(9)、修改root密码

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> update user set authentication_string='' where user='root';
Query OK, 1 row affected (0.08 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MysqL> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MysqL> exit;
Bye

注释my.cnf文件“跳过数据库权限验证”

在这里插入图片描述


杀掉进程,重启服务

在这里插入图片描述


(10)、再次修改root密码并开启远程访问

[app@localhost bin]$ ./MysqL -S /uploaddir/MysqL-8.0.26-8080/tmp/MysqL.sock -uroot -p
Enter password: 直接回车
Welcome to the MysqL monitor.  Commands end with ; or \g.
Your MysqL connection id is 10
Server version: 8.0.26

copyright (c) 2000, 2021, Oracle and/or its affiliates.

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 WITH MysqL_native_password BY 'root';
Query OK, 0 rows affected (0.02 sec)

MysqL> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MysqL> exit;
Bye

开启远程访问

[app@localhost bin]$ ./MysqL -S /uploaddir/MysqL-8.0.26-8080/tmp/MysqL.sock -uroot -p
Enter password: root
Welcome to the MysqL monitor.  Commands end with ; or \g.
Your MysqL connection id is 11
Server version: 8.0.26 MysqL Community Server - GPL

copyright (c) 2000, 2021, Oracle and/or its affiliates.

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> 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> update user set host='%' where user='root';
Query OK, 1 row affected (0.04 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MysqL> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MysqL> exit;
Bye

(11)、本地用Navicat连接验证是否安装成功

在这里插入图片描述

相关文章

显卡天梯图2024最新版,显卡是电脑进行图形处理的重要设备,...
初始化电脑时出现问题怎么办,可以使用win系统的安装介质,连...
todesk远程开机怎么设置,两台电脑要在同一局域网内,然后需...
油猴谷歌插件怎么安装,可以通过谷歌应用商店进行安装,需要...
虚拟内存这个名词想必很多人都听说过,我们在使用电脑的时候...