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连接验证是否安装成功
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值