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安装包
[root@rhel6lhr local]# cd -
/data
[root@rhel6lhr data]# ls
apache-tomcat-7.0.79 mysql
apache-tomcat-7.0.79.zip mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
jdk1.8.0_291 mysql-8.0.25-1.el6.x86_64.rpm-bundle.tar
jdk-8u291-linux-x64.tar.gz
[root@rhel6lhr data]# tar -zxvf mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
[root@rhel6lhr data]# mv mysql-8.0.11-linux-glibc2.12-x86_64 mysql8.0
[root@rhel6lhr data]# groupadd mysql
[root@rhel6lhr data]# useradd -r -g mysql mysql
[root@rhel6lhr data]# chown -R mysql:mysql mysql8.0/
[root@rhel6lhr mysql8.0]# ./bin/mysqld --initialize --basedir=/data/mysql8.0 --datadir=/data/mysql8.0/data --user=mysql
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
2021-06-23T16:32:36.076474Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Bkqzp:sri0lx
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
[root@rhel6lhr mysql]# service mysql start
Starting MySQL.[ OK ]
[root@rhel6lhr mysql]# service mysql status;
MySQL running (23535)[ OK ]
[root@rhel6lhr mysql8.0]# pwd
/data/mysql8.0
[root@rhel6lhr mysql8.0]# ./bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.11
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 WITH mysql_native_password BY 'root';
Query OK, 0 rows affected (0.03 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' from user where user='root';
+------+
| host |
+------+
| host |
+------+
1 row in set (0.00 sec)
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> select 'host' from user where user='root';
+------+
| host |
+------+
| host |
+------+
1 row in set (0.00 sec)
mysql> exit