Windows下安装解压版MySQL5.5
1、Windows 下载mysql-5.5.61-winx64.zip到D盘根目录、解压。
2、移动D:\mysql-5.5.61-winx64目录下所有的ini文件到备份目录下,创建或者复制my-medium.ini文件my.ini文件。
3、编辑my.ini配置文件,加入以下内容
[client]
port = 3306
default-character-set = utf8
或者以宽松模式设置字符集
loose-default-character-set = utf8
[mysqld]
character-set-server = utf8
或者以宽松模式设置字符集
loose-character-set-server = utf8
解压路径
basedir = D:\mysql-5.5.61-winx64
datadir = D:\mysql-5.5.61-winx64\data
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-winx64\bin\mysqld.exe
4.设置环境变量
在环境变量path中加入mysql路径,计算机—>右击“属性”—>高级系统设置—>高级—>环境变量(N)—>修改Path;
将复制的地址栏粘贴到最后。(这里注意的是不同的路径之间用英文的“;”分开)确定,退出。
5.以管理员身份运行cmd(一定要用管理员身份运行,不然权限不够)
具体方法是:右击命令提示符窗口,选择“以管理员身份运行”。
然后在命令提示符窗口中,进到MySQL解压目录下的bin文件(不管有没有配置过环境变量,也要进入bin文件夹,否则之后启动服务仍然会报错误):
cd /d D:\mysql-5.5.61-winx64\bin
6.初始化数据库
mysqld --initialize-insecure --defaults-file=D:\mysql-5.5.61-winx64\my.ini --user=mysql
【命令mysqld --initialize-insecure --user=mysql的作用:使用-initialize初始化,用-insecure生成空密码。默认帐号root,后面的-user=mysql不更改。】
D:\mysql-5.5.61-winx64\bin>mysqld --initialize-insecure --defaults-file=D:\mysq-5.5.61-winx64\my.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-winx64\bin>
7.安装MySQL服务
D:\mysql-5.5.61-winx64\bin> mysqld install MySQL5.5
Service successfully installed.
删除MySQL服务
D:\mysql-5.5.61-winx64\bin> mysqld remove MySQL5.5
8.启动服务
D:\mysql-5.5.61-winx64\bin>net start MySQL5.5
MySQL5.5 服务正在启动 .
MySQL5.5 服务已经启动成功。
D:\mysql-5.5.61-winx64\bin>
注意:如果之前没有运行第7步命令:mysqld --initialize-insecure --user=mysql,可能会造成服务不能启动。 (这时应该先用命令mysqld -remove卸载mysql,再运行该命令)
9.登陆数据库
D:\mysql-5.5.61-winx64\bin>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-winx64\data\ |
+------------------------------+
1 row in set (0.00 sec)
修改root用户密码
mysql> update mysql.user set password = PASSWORD('mysql123') where User = 'root';
Query OK, 3 rows affected (0.02 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql>
本文来自博客园,作者:花之旭,转载请注明原文链接:https://www.cnblogs.com/huazhixu/p/16589850.html