赞
踩
注意:你这里刚刚解压之后的目录里面是没有下面的“Data”文件夹和“my.ini”文件的,这是后面安装步骤中会陆续生成的。
[mysqld] # 设置3306端口 port=3306 # 设置mysql的安装目录 basedir=E:\\software\\mysql\\mysql-8.0.11-winx64 # 此处最好用双斜杠\\,其他的可能会报错 # 设置mysql数据库的数据的存放目录 datadir=E:\\software\\mysql\\mysql-8.0.11-winx64\\Data # 此处同上 # 允许最大连接数 max_connections=200 # 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统 max_connect_errors=10 # 服务端使用的字符集默认为UTF8 character-set-server=utf8 # 创建新表时将使用的默认存储引擎 default-storage-engine=INNODB # 默认使用“mysql_native_password”插件认证 default_authentication_plugin=mysql_native_password [mysql] # 设置mysql客户端默认字符集 default-character-set=utf8 [client] # 设置mysql客户端连接服务端时默认使用的端口 port=3306 default-character-set=utf8
注意:如果你电脑的文件默认不显示后缀的话,可以在文件夹中点击“查看”,选中“文件扩展名”,就可以看到文件的后缀都显示出来了(不同版本的windows系统可能界面略有不同,可以自行百度),方便将新建的“.txt”改成我们这里的“.ini”,如下图:
C:\Windows\System32>cd /d "D:\Program Files\mysql-8.0.11-winx64\bin"
D:\Program Files\mysql-8.0.11-winx64\bin>mysqld --initialize --console
2020-07-26T08:35:27.336677Z 0 [System] [MY-013169] [Server] D:\Program Files\mysql-8.0.11-winx64\bin\mysqld.exe (mysqld 8.0.11) initializing of server in progress as process 11720
2020-07-26T08:35:30.098747Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: /d/joRygB9?1
2020-07-26T08:35:31.415521Z 0 [System] [MY-013170] [Server] D:\Program Files\mysql-8.0.11-winx64\bin\mysqld.exe (mysqld 8.0.11) initializing of server has completed
如上所示,输出的“/d/joRygB9?1”就是你的初始密码(注意:不要包含前后的空格),这里我们先记住这个密码,后面再修改成我们自己的密码。
注意:如果不小心忘记了这个初始密码,可以删掉初始化的 Data 目录,重新执行一遍上面的初始化命令“mysqld --initialize --console”,又会重新生成的了。
D:\Program Files\mysql-8.0.11-winx64\bin>mysqld --install mysql8
Service successfully installed.
D:\Program Files\mysql-8.0.11-winx64\bin>net start mysql8
mysql8 服务正在启动 .
mysql8 服务已经启动成功。
注意:要停止的话使用命令“net stop mysql”;
要卸载mysql服务的话,使用命令sc delete MySQL/mysqld -remove卸载 。
D:\Program Files\mysql-8.0.11-winx64\bin>mysql -u root -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 '新密码'; Query OK, 0 rows affected (0.12 sec)
至此,mysql就安装完成了,可是使用了,如:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)
mysql> select user,host,authentication_string from mysql.user;
+------------------+-----------+-------------------------------------------+
| user | host | authentication_string |
+------------------+-----------+-------------------------------------------+
| mysql.infoschema | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| root | localhost | *539713D14B16BEA35BBCEF7D9CC253B7DACA75F4 |
+------------------+-----------+-------------------------------------------+
4 rows in set (0.00 sec)
mysql>
mysql> exit
Bye
Microsoft Windows [版本 10.0.18363.959] (c) 2019 Microsoft Corporation。保留所有权利。 C:\Windows\system32>net start mysql8 mysql8 服务正在启动 . mysql8 服务已经启动成功。 C:\Windows\system32>mysql -u root -p Enter password: ********* Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 8.0.11 MySQL Community Server - GPL 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec) mysql> use mysql; Database changed mysql> show tables; +---------------------------+ | Tables_in_mysql | +---------------------------+ | columns_priv | | component | | db | | default_roles | | engine_cost | | func | | general_log | | global_grants | | gtid_executed | | help_category | | help_keyword | | help_relation | | help_topic | | innodb_index_stats | | innodb_table_stats | | password_history | | plugin | | procs_priv | | proxies_priv | | role_edges | | server_cost | | servers | | slave_master_info | | slave_relay_log_info | | slave_worker_info | | slow_log | | tables_priv | | time_zone | | time_zone_leap_second | | time_zone_name | | time_zone_transition | | time_zone_transition_type | | user | +---------------------------+ 33 rows in set (0.01 sec) mysql> exit Bye C:\Windows\system32>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。