1, 打开官方网站,下载mysql
https://dev.mysql.com/downloads/file/?id=495278
公司内部SERVER,无法连外网,采用源码包
安装步骤:
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar xvf /path/to/mysql-VERSION-OS.tar.xz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> mkdir mysql-files
shell> chown mysql:mysql mysql-files
shell> chmod 750 mysql-files
shell> bin/mysqld --initialize --user=mysql
2020-06-01T09:53:48.853319Z 0 [System] [MY-013169] [Server] /export/servers/mysql-8.0.20-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.20) initializing of server in progress as process 35791
2020-06-01T09:53:48.861698Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-06-01T09:54:01.517524Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-06-01T09:54:11.657038Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: z1HI0j(?!h/n
shell> bin/mysql_ssl_rsa_setup
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
登陆: 使用刚刚初始化生成的密码:z1HI0j(?!h/n
登陆后必须要修改初始密码,否则其他的命令都无法执行; 会报错:ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
修改初始密码的SQL: alter user root@localhost identified by 'password';
root@A01-R07-07-I133-131 mysql]# 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.20
Copyright (c) 2000, 2020, 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>
mysql>
mysql> select @@version;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>
mysql> alter user root@localhost identified by 'root01';
Query OK, 0 rows affected (0.17 sec)
mysql> select @@version;
+-----------+
| @@version |
+-----------+
| 8.0.20 |
+-----------+
1 row in set (0.00 sec)
查看版本,显示8.0.20