mysql8安装和驱动jar包下载

方式一:基于docker安装
下拉镜像

docker pull mysql:8.0.21

启动镜像
docker run -p 3307:3306 --name mysql -e MYSQL_ROOT_PASSWORD=hadoop -d mysql:8.0.21

启动成功后,进入容器内部拷贝配置文件,到宿主主机
docker cp mysql:/etc/mysql /home/summer/mysql8

拷贝容器的 /etc/mysql目录到 主机目录/home/summer/mysql8

删除mysql容器,重新创建容器
docker stop mysql docker rm mysql

启动mysql ,挂载配置文件,数据持久化到宿主主机
启动脚本 文件名为mysql8.0.21.sh

  1. #!/bin/sh

  2. docker run \

  3. -p 3307:3306 \

  4. --name mysql \

  5. --privileged=true \

  6. --restart unless-stopped \

  7. -v /home/summer/mysql8/mysql:/etc/mysql \

  8. -v /home/summer/mysql8/logs:/logs \

  9. -v /home/summer/mysql8/data:/var/lib/mysql \

  10. -v /etc/localtime:/etc/localtime \

  11. -e MYSQL_ROOT_PASSWORD=hadoop \

  12. -d mysql:8.0.21

命令解释: -p 端口映射

--privileged=true 挂载文件权限设置

--restart unless-stopped 设置 开机后自动重启容器

-v /home/summer/mysql8/mysql:/etc/mysql 挂载配置文件

-v /home/summer/mysql8/logs:/logs \ 挂载日志

-v /home/summer/mysql8/data:/var/lib/mysql \ 挂载数据文件 持久化到主机,

-v /etc/localtime:/etc/localtime 容器时间与宿主机同步

-e MYSQL_ROOT_PASSWORD=hadoop 设置密码

-d mysql:8.0.21 后台启动,mysql

执行脚本 启动镜像

大功告成,挂载出来了数据文件以及配置文件实现数据持久化

 
  1. ALTER USER "root"@"localhost" IDENTIFIED BY "hadoop";

  2. FLUSH PRIVILEGES;

  3. create user summer@'%' identified by '123456';

  4. grant all privileges on *.* to summer@'%' with grant option;

  5. exit;

  6. use mysql;

  7. update user set host = '%' where user ='summer';

  8. ALTER USER 'summer'@'%' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;

  9. ALTER USER 'summer'@'%' IDENTIFIED WITH mysql_native_password BY '123456';

  10. exit;

方式二:正常tar包安装
上传安装包并解压
  1. root in summer in /home/soft

  2. ❯ ll

  3. total 473712

  4. -r-------- 1 root root 485074552 May 17 09:51 mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz

  5. root in summer in /home/soft

  6. ➜ du -sh *

  7. 463M mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz

  8. root in summer in /home/soft

  9. ➜ tar -xvf mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz

移动重命名
  1. root in summer in /home/soft took 2m

  2. ➜ ll

  3. total 473716

  4. drwxr-xr-x 9 root root 4096 May 17 10:43 mysql-8.0.19-linux-glibc2.12-x86_64

  5. -r-------- 1 root root 485074552 May 17 09:51 mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz

  6. root in summer in /home/soft

  7. ➜ mv mysql-8.0.19-linux-glibc2.12-x86_64 /usr/local/

  8. root in summer in /home/soft

  9. ➜ cd /usr/local/ && mv mysql-8.0.19-linux-glibc2.12-x86_64/ mysql

  10. root in summer in /usr/local

  11. ➜ ll

  12. total 60

  13. drwxr-xr-x 9 nobody nobody 4096 Apr 25 10:27 ats

  14. drwxr-xr-x. 3 root root 4096 Apr 25 12:14 bin

  15. drwxr-xr-x. 4 root root 4096 Apr 25 12:12 etc

  16. drwxr-xr-x. 2 root root 4096 Apr 11 2018 games

  17. drwxr-xr-x. 5 root root 4096 Apr 25 10:51 include

  18. drwxr-xr-x. 5 root root 4096 Apr 25 10:51 lib

  19. drwxr-xr-x. 2 root root 4096 Apr 11 2018 lib64

  20. drwxr-xr-x. 2 root root 4096 Apr 11 2018 libexec

  21. drwxr-xr-x 2 root root 4096 Apr 25 10:27 man

  22. drwxr-xr-x 9 root root 4096 May 17 10:43 mysql

  23. lrwxrwxrwx 1 root root 20 Apr 25 10:52 python374 -> /usr/local/python377

  24. drwxr-xr-x 6 root root 4096 Apr 25 10:52 python377

  25. drwxr-xr-x. 2 root root 4096 Apr 25 10:51 sbin

  26. drwxr-xr-x. 7 root root 4096 Apr 25 10:51 share

  27. drwxr-xr-x. 2 root root 4096 Apr 11 2018 src

  28. drwxr-xr-x 3 root root 4096 Apr 25 10:51 var

  29. root in summer in /usr/local

新增mysql用户
  1. root in summer in /usr/local

  2. ➜ cd mysql/

  3. root in summer in /usr/local/mysql

  4. ➜ ll

  5. total 432

  6. drwxr-xr-x 2 7161 31415 4096 Dec 10 2019 bin

  7. drwxr-xr-x 2 7161 31415 4096 Dec 10 2019 docs

  8. drwxr-xr-x 3 7161 31415 4096 Dec 10 2019 include

  9. drwxr-xr-x 6 7161 31415 4096 Dec 10 2019 lib

  10. -rw-r--r-- 1 7161 31415 405571 Dec 10 2019 LICENSE

  11. drwxr-xr-x 4 7161 31415 4096 Dec 10 2019 man

  12. -rw-r--r-- 1 7161 31415 687 Dec 10 2019 README

  13. drwxr-xr-x 28 7161 31415 4096 Dec 10 2019 share

  14. drwxr-xr-x 2 7161 31415 4096 Dec 10 2019 support-files

  15. root in summer in /usr/local/mysql

  16. ➜ mkdir data

  17. root in summer in /usr/local/mysql

  18. ➜ groupadd mysql

  19. root in summer in /usr/local/mysql

  20. ➜ useradd -g mysql mysql

  21. root in summer in /usr/local/mysql

  22. ➜ chown -R mysql:mysql /usr/local/mysql/

  23. root in iscloud163-200 in /usr/local/etc

  24. ❯ mkdir /var/log/mariadb

  25. root in iscloud163-200 in /usr/local/etc

  26. ➜ touch /var/log/mariadb/mariadb.log

  27. root in iscloud163-200 in /usr/local/etc

  28. ➜ chown -R mysql:mysql /var/log/mariadb/

初始化
  1. root in summer in /usr/local/mysql

  2. ➜ /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

  3. 2021-05-17T02:46:09.950578Z 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.

  4. 2021-05-17T02:46:09.950757Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.19) initializing of server in progress as process 1868276

  5. 2021-05-17T02:46:18.144914Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: bkXul9__qP*8

修改配置文件
  • 注意skip-grant-tables该参数为修改root密码
  1. root in summer in ~

  2. ➜ cat /etc/my.cnf

  3. [mysqld]

  4. basedir=/usr/local/mysql

  5. datadir=/usr/local/mysql/data

  6. port=23306

  7. user=mysql

  8. socket=/tmp/mysql.sock

  9. # Disabling symbolic-links is recommended to prevent assorted security risks

  10. symbolic-links=0

  11. # Settings user and group are ignored when systemd is used.

  12. # If you need to run mysqld under a different user or group,

  13. # customize your systemd unit file for mariadb according to the

  14. # instructions in http://fedoraproject.org/wiki/Systemd

  15. #skip-grant-tables

  16. [mysqld_safe]

  17. log-error=/var/log/mariadb/mariadb.log

  18. pid-file=/var/run/mariadb/mariadb.pid

  19. #

  20. # include all files from the config directory

  21. #

  22. !includedir /etc/my.cnf.d

添加系统服务
  1. root in summer in /usr/local/mysql

  2. ❯ cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

  3. root in summer in /usr/local/mysql

  4. ➜ chmod +x /etc/rc.d/init.d/mysqld

  5. root in summer in /usr/local/mysql

  6. ➜ chkconfig --add mysqld

配置环境变量
  1. ❯ vim /etc/profile

  2. root in summer in /usr/local/mysql took 16s

  3. ➜ source /etc/profile

  4. root in summer in /usr/local/mysql

  5. ❯ ln -s /usr/local/mysql/bin/mysql /usr/bin

  6. root in summer in /usr/local/mysql

  7. ➜ ln -s /usr/local/mysql/bin/mysqld /usr/bin

定义root密码
  1. root in summer in /usr/local/mysql

  2. ➜ /etc/init.d/mysqld restart

  3. MySQL server PID file could not be found! [FAILED]

  4. Starting MySQL..... [ OK ]

  5. root in summer in /usr/local/mysql

  6. ➜ mysql

  7. Welcome to the MySQL monitor. Commands end with ; or \g.

  8. Your MySQL connection id is 7

  9. Server version: 8.0.19 MySQL Community Server - GPL

  10. Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

  11. Oracle is a registered trademark of Oracle Corporation and/or its

  12. affiliates. Other names may be trademarks of their respective

  13. owners.

  14. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  15. mysql> use mysql;

  16. Reading table information for completion of table and column names

  17. You can turn off this feature to get a quicker startup with -A

  18. Database changed

  19. mysql> update user set authentication_string='' where user='root';

  20. Query OK, 1 row affected (0.01 sec)

  21. Rows matched: 1 Changed: 1 Warnings: 0

  22. mysql> flush privileges;

  23. Query OK, 0 rows affected (0.00 sec)

  24. mysql> ALTER user 'root'@'localhost' IDENTIFIED BY 'hadoop';

  25. Query OK, 0 rows affected (0.18 sec)

  26. mysql> \q

  27. Bye

  28. root in summer in /usr/local/mysql took 2m37s

  29. ➜ vim /etc/my.cnf ##这里注释掉skip-grant-tables

  30. root in summer in /usr/local/mysql took 10s

  31. ➜ /etc/init.d/mysqld restart

  32. Shutting down MySQL.. [ OK ]

  33. Starting MySQL... [ OK ]

验证版本并登录
  1. root in summer in local/mysql/data

  2. ➜ ps -ef | grep mysql

  3. root 1945961 1 0 11:01 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/summer.pid

  4. mysql 1946194 1945961 0 11:01 ? 00:00:10 /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=/var/log/mariadb/mariadb.log --pid-file=/usr/local/mysql/data/summer.pid --socket=/tmp/mysql.sock --port=23306

  5. root 2075003 2049242 0 11:39 pts/3 00:00:00 grep --color=auto mysql

  6. root in summer in /usr/local/mysql

  7. ❯ mysql -V

  8. mysql Ver 8.0.19 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)

  9. root in summer in /usr/local/mysql took 6s

  10. ➜ mysql -u root -p

  11. Enter password:

  12. Welcome to the MySQL monitor. Commands end with ; or \g.

  13. Your MySQL connection id is 8

  14. Server version: 8.0.19 MySQL Community Server - GPL

  15. Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

  16. Oracle is a registered trademark of Oracle Corporation and/or its

  17. affiliates. Other names may be trademarks of their respective

  18. owners.

  19. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  20. mysql>

下载mysql驱动jar包

进入官网 MySQL 点击DOWNLOADS

然后拉到最下面,点击MySQL Community(GPL) Downloads

然后选择Connector/J,这里的J是Java的意思

这里如果是windows用户的话,选择Platform Independent,如果是其他用户就选其他版本

点击Download

 

总结:

感谢每一个认真阅读我文章的人!!!

作为一位过来人也是希望大家少走一些弯路,如果你不想再体验一次学习时找不到资料,没人解答问题,坚持几天便放弃的感受的话,在这里我给大家分享一些自动化测试的学习资源,希望能给你前进的路上带来帮助。

软件测试面试文档

我们学习必然是为了找到高薪的工作,下面这些面试题是来自阿里、腾讯、字节等一线互联网大厂最新的面试资料,并且有字节大佬给出了权威的解答,刷完这一套面试资料相信大家都能找到满意的工作。

 

          视频文档获取方式:
这份文档和视频资料,对于想从事【软件测试】的朋友来说应该是最全面最完整的备战仓库,这个仓库也陪伴我走过了最艰难的路程,希望也能帮助到你!以上均可以分享,点下方小卡片即可自行领取。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值