安装 mysql

一、CentOS7 install mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar

1、download and upload to CentOS7 "mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar"

2、install

 1 [root@liuhonglei ~]# ls
 2 anaconda-ks.cfg  easy-mock  mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar
 3 [root@liuhonglei ~]#mkdir /usr/local/mysql/ && mv mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar /usr/local/mysql/
 4 [root@liuhonglei ~]# cd /usr/local/mysql/
 5 [root@liuhonglei mysql]# ls
 6 mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar
 7 [root@liuhonglei mysql]# tar -xvf mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar  
 8 mysql-community-libs-8.0.20-1.el7.x86_64.rpm
 9 mysql-community-embedded-compat-8.0.20-1.el7.x86_64.rpm
10 mysql-community-test-8.0.20-1.el7.x86_64.rpm
11 mysql-community-common-8.0.20-1.el7.x86_64.rpm
12 mysql-community-devel-8.0.20-1.el7.x86_64.rpm
13 mysql-community-client-8.0.20-1.el7.x86_64.rpm
14 mysql-community-libs-compat-8.0.20-1.el7.x86_64.rpm
15 mysql-community-server-8.0.20-1.el7.x86_64.rpm
16 [root@liuhonglei mysql]# rpm -ivh mysql-community-common-8.0.20-1.el7.x86_64.rpm --nodeps --force
17 [root@liuhonglei mysql]# rpm -ivh mysql-community-libs-8.0.20-1.el7.x86_64.rpm --nodeps --force
18 [root@liuhonglei mysql]# rpm -ivh mysql-community-client-8.0.20-1.el7.x86_64.rpm --nodeps --force
19 [root@liuhonglei mysql]# rpm -ivh mysql-community-server-8.0.20-1.el7.x86_64.rpm --nodeps --force
20 [root@liuhonglei mysql]# mysqld --initialize
21 [root@liuhonglei mysql]# chown mysql:mysql /var/lib/mysql -R
22 [root@liuhonglei mysql]# systemctl start mysqld.service
23 [root@liuhonglei mysql]# systemctl enable mysqld
24 [root@liuhonglei mysql]# cat /var/log/mysqld.log|grep password 
25 2020-07-18T00:19:30.205562Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: =&uZyx=8+)e<
26 [root@liuhonglei mysql]# mysql -u root -p
27 Enter password: 
28 Welcome to the MySQL monitor.  Commands end with ; or \g.
29 mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'lhl545366';
30 Query OK, 0 rows affected (0.12 sec)
31 mysql> flush privileges;
32 Query OK, 0 rows affected (0.06 sec)
33 mysql> create user 'root'@'192.168.1.100' identified with mysql_native_password by 'lhl545366';
34 Query OK, 0 rows affected (0.69 sec)
35 mysql> grant all privileges on *.* to 'root'@'192.168.1.100' with grant option;
36 Query OK, 0 rows affected (0.17 sec)
37 mysql> flush privileges;
38 Query OK, 0 rows affected (0.05 sec)
39 mysql> quit;
40 [root@liuhonglei mysql]# firewall-cmd --get-zones
41 block dmz drop external home internal public trusted work
42 [root@liuhonglei mysql]# firewall-cmd --zone=public --permanent --add-port=3306/tcp
43 success
44 [root@liuhonglei mysql]# firewall-cmd --reload
45 success

 二、windows10 install mysql-8.0.21-winx64.zip

1、download and upload to windows10 "mysql-8.0.21-winx64.zip"(D:\software\mysql)

2、install

(1) create "my.ini" in "mysql-8.0.21-winx64"

 1 [mysql]
 2 default-character-set=UTF8MB4
 3 
 4 [mysqld]
 5 port=3306
 6 basedir=D:/software/mysql/mysql-8.0.21-winx64
 7 datadir=D:/software/mysql/mysql-8.0.21-winx64/data
 8 max_connections=200
 9 max_connect_errors=10
10 character-set-server=UTF8MB4
11 default-storage-engine=INNODB
12 default_authentication_plugin=mysql_native_password
13 
14 [client]
15 port=3306
16 default-character-set=UTF8MB4

(2) create "data" directory(D:\software\mysql\mysql-8.0.21-winx64\data)

(3) open command line run as an administrator,come into  "D:\software\mysql\mysql-8.0.21-winx64\bin"

(4)execute commands:

 1 C:\Windows\system32>d:
 2 D:\> cd D:\software\mysql\mysql-8.0.21-winx64\bin
 3 D:\software\mysql\mysql-8.0.21-winx64\bin>mysqld --initialize --console
 4     2020-07-18T11:30:31.656354Z 0 [System] [MY-013169] [Server] 
 5     D:\software\mysql\mysql-8.0.21-winx64\bin\mysqld.exe (mysqld 8.0.21) 
 6     initializing of server in progress as process 14476
 7     2020-07-18T11:30:31.668323Z 1 [System] [MY-013576] [InnoDB] InnoDB 
 8     initialization has started.
 9     2020-07-18T11:30:31.997343Z 1 [System] [MY-013577] [InnoDB] InnoDB 
10     initialization has ended.
11     2020-07-18T11:30:32.697273Z 6 [Note] [MY-010454] [Server] A temporary 
12     password is generated for root@localhost: d4uleHdC,hs? 
13 D:\software\mysql\mysql-8.0.21-winx64\bin>mysqld --install
14     The service already exists!
15     The current server installed: D:\software\mysql\mysql-8.0.21- 
16     winx64\bin\mysqld MySQL
17 D:\software\mysql\mysql-8.0.21-winx64\bin>net start mysql
18     MySQL 服务正在启动 .
19     MySQL 服务已经启动成功。
20 D:\software\mysql\mysql-8.0.21-winx64\bin>mysql -u root -p
21     Enter password: ************
22 mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'lhl545366';
23     Query OK, 0 rows affected (0.00 sec)
24 mysql> grant all privileges on *.* to 'root'@'localhost' with grant option;
25     Query OK, 0 rows affected (0.00 sec)
26 mysql> flush privileges;
27     Query OK, 0 rows affected (0.00 sec)

 三、Docker install mysql

1、docker pull centos/mysql-57-centos7

2、docker run ‐di ‐‐name=my_mysql ‐p 3306:3306 ‐e MYSQL_ROOT_PASSWORD=root centos/mysql‐57‐centos7

posted @ 2020-07-18 08:57  遥~  阅读(644)  评论(0编辑  收藏  举报