Windows下安装MySQL5.5

1、下载mysql-5.5.61-winx64.zip到D盘根目录、解压。

2、移动D:mysql-5.5.61-winx64目录下所有的ini文件到备份目录下,创建文件my.ini文件。

3、编辑my.ini文件,加入以下内容
[client]
port = 3306
default-character-set = utf8

[mysqld]
character-set-server = utf8
basedir = D:mysql-5.5.61-winx64
datadir = D:mysql-5.5.61-winx64data
port = 3306
skip-external-locking
log-bin = mysql-bin
binlog_format = mixed
max_connections = 2000
skip-networking
server-id = 1
shared-memory

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M

[mysqlhotcopy]
interactive-timeout

[WinMySQLadmin]
Server = D:mysql-5.5.61-winx64binmysqld.exe

4.在环境变量path中加入mysql路径,计算机—>右击“属性”—>高级系统设置—>高级—>环境变量(N)—>修改Path;就是将复制的地址栏粘贴到最后。
(这里注意的是不同的路径之间用英文的“;”分开)确定,退出。

5.以管理员身份运行cmd(一定要用管理员身份运行,不然权限不够),具体方法是:右击命令提示符窗口,选择“以管理员身份运行”。
然后在命令提示符窗口中,进到MySQL解压目录下的bin文件(不管有没有配置过环境变量,也要进入bin文件夹,否则之后启动服务仍然会报错误):
cd /d D:mysql-5.5.61-winx64bin

6.初始化
mysqld --initialize-insecure --defaults-file=D:mysql-5.5.61-winx64my.ini --user=mysql

(使用-initialize初始化,用-insecure生成空密码。默认帐号root,后面的-user=mysql不更改。)
D:mysql-5.5.61-winx64bin>mysqld --initialize-insecure --defaults-file=D:mysq-5.5.61-winx64my.ini --user=mysql
220815 21:57:03 [Note] --secure-file-priv is set to NULL. Operations related to
importing and exporting data are disabled
220815 21:57:03 [Note] mysqld (mysqld 5.5.61-log) starting as process 2220 ...
D:mysql-5.5.61-winx64bin>

7.安装MySQL服务
D:mysql-5.5.61-winx64bin> mysqld install MySQL5.5
Service successfully installed.

删除MySQL服务
D:mysql-5.5.61-winx64bin> mysqld remove MySQL5.5

8.启动服务
D:mysql-5.5.61-winx64bin>net start MySQL5.5
MySQL5.5 服务正在启动 .
MySQL5.5 服务已经启动成功。
D:mysql-5.5.61-winx64bin>

注意:如果之前没有运行第7步命令:mysqld --initialize-insecure --user=mysql ,可能会造成服务不能启动。 (这时应该先用命令mysqld -remove卸载mysql,再运行该命令)
命令mysqld --initialize-insecure --user=mysql的作用:使用-initialize初始化,用-insecure生成空密码。默认帐号root,后面的-user=mysql不更改。

9.登陆
D:mysql-5.5.61-winx64bin>mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.5.61-log 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> s
--------------
mysql Ver 14.14 Distrib 5.5.61, for Win64 (AMD64)
Connection id: 1
Current database:
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.5.61-log MySQL Community Server (GPL)
Protocol version: 10
Connection: Shared memory: MYSQL
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
TCP port: 3306
Uptime: 1 min 22 sec
Threads: 1 Questions: 5 Slow queries: 0 Opens: 33 Flush tables: 1 Open tab
es: 26 Queries per second avg: 0.060
--------------
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)

mysql> select version();
+------------+
| version() |
+------------+
| 5.5.61-log |
+------------+
1 row in set (0.00 sec)

mysql> select @@basedir;
+------------------------+
| @@basedir |
+------------------------+
| D:mysql-5.5.61-winx64 |
+------------------------+
1 row in set (0.00 sec)

mysql>
mysql> select @@datadir;
+------------------------------+
| @@datadir |
+------------------------------+
| D:mysql-5.5.61-winx64data |
+------------------------------+
1 row in set (0.00 sec)
mysql>

展开阅读全文

页面更新:2024-05-16

标签:会报   帐号   初始化   路径   环境变量   命令   管理员   身份   密码   文件

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top