Linux安装MySQL8.0

1、https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz 下载mysql安装包

  1. [root@rhel6lhr local]# cd -
  2. /data
  3. [root@rhel6lhr data]# ls
  4. apache-tomcat-7.0.79 mysql
  5. apache-tomcat-7.0.79.zip mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
  6. jdk1.8.0_291 mysql-8.0.25-1.el6.x86_64.rpm-bundle.tar
  7. jdk-8u291-linux-x64.tar.gz
  8. [root@rhel6lhr data]# tar -zxvf mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
  9. [root@rhel6lhr data]# mv mysql-8.0.11-linux-glibc2.12-x86_64 mysql8.0
  10. [root@rhel6lhr data]# groupadd mysql
  11. [root@rhel6lhr data]# useradd -r -g mysql mysql
  12. [root@rhel6lhr data]# chown -R mysql:mysql mysql8.0/
  13. [root@rhel6lhr mysql8.0]# ./bin/mysqld --initialize --basedir=/data/mysql8.0 --datadir=/data/mysql8.0/data --user=mysql
  14. 2021-06-23T16:32:33.928437Z 0 [System] [MY-013169] [Server] /data/mysql8.0/bin/mysqld (mysqld 8.0.11) initializing of server in progress as process 22211
  15. 2021-06-23T16:32:36.076474Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Bkqzp:sri0lx
  16. 2021-06-23T16:32:36.896864Z 0 [System] [MY-013170] [Server] /data/mysql8.0/bin/mysqld (mysqld 8.0.11) initializing of server has completed
  17. [root@rhel6lhr mysql]# service mysql start
  18. Starting MySQL.[ OK ]
  19. [root@rhel6lhr mysql]# service mysql status;
  20. MySQL running (23535)[ OK ]
  21. [root@rhel6lhr mysql8.0]# pwd
  22. /data/mysql8.0
  23. [root@rhel6lhr mysql8.0]# ./bin/mysql -uroot -p
  24. Enter password:
  25. Welcome to the MySQL monitor. Commands end with ; or \g.
  26. Your MySQL connection id is 8
  27. Server version: 8.0.11
  28. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  29. Oracle is a registered trademark of Oracle Corporation and/or its
  30. affiliates. Other names may be trademarks of their respective
  31. owners.
  32. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  33. mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
  34. Query OK, 0 rows affected (0.03 sec)
  35. mysql> use mysql;
  36. Reading table information for completion of table and column names
  37. You can turn off this feature to get a quicker startup with -A
  38. Database changed
  39. mysql> select 'host' from user where user='root';
  40. +------+
  41. | host |
  42. +------+
  43. | host |
  44. +------+
  45. 1 row in set (0.00 sec)
  46. mysql> update user set host = '%' where user ='root';
  47. Query OK, 1 row affected (0.04 sec)
  48. Rows matched: 1 Changed: 1 Warnings: 0
  49. mysql> flush privileges;
  50. Query OK, 0 rows affected (0.00 sec)
  51. mysql> select 'host' from user where user='root';
  52. +------+
  53. | host |
  54. +------+
  55. | host |
  56. +------+
  57. 1 row in set (0.00 sec)
  58. mysql> exit