search
HomeDatabaseMysql TutorialWIndows 系统下安装mysql-noinstall版本_MySQL

     友情提示:本文针对mysql-noinstall版本,也就是解压缩版的安装配置应用做了个总结,这些操作都是平时很常用的操作。


本文针对mysql-noinstall版本,也就是解压缩版的安装配置应用做了个总结,这些操作都是平时很常用的操作。文章中不对mysql的可执行文件安装版做介绍了,可执行安装版有很多的弊端,我也不一一说了。总之,我喜欢绿色环保的,包括eclipse、tomcat、jboss、apache也是,即使操作系统重装了,这些软件也不需要重装,可谓一劳永逸!

环境:
Windows 2000/XP/2003
mysql-noinstall-5.0.37-win32.zip

一、下载MySQL

http://www.mysql.com/downloads

二、安装过程

1、解压缩mysql-noinstall-5.0.37-win32.zip到一个目录,加入解压缩到E:/myserver目录。

2、编写mysql的运行配置文件my.ini
my.ini
-----------------------------
[WinMySQLAdmin]
# 指定mysql服务启动启动的文件
Server=E://myserver//mysql-5.0.37-win32//bin//mysqld-nt.exe

[mysqld]
# 设置mysql的安装目录
basedir=E://myserver//mysql-5.0.37-win32
# 设置mysql数据库的数据的存放目录,必须是data,或者是//xxx/data
datadir=E://myserver//mysql-5.0.37-win32//data
# 设置mysql服务器的字符集
default-character-set=gbk

[client]
# 设置mysql客户端的字符集
default-character-set=gbk
-----------------------------

3、安装mysql服务
从MS-DOS窗口进入目录E:/myserver/mysql-5.0.37-win32/bin,运行如下命令:
mysqld --install mysql5 --defaults-file= E:/myserver/mysql-5.0.37-win32/my.ini

4、启动mysql数据库
还在上面的命令窗口里面,输入命令:net start mysql5
这样就启动了mysql服务。

5、(本地)登录mysql数据库
还在上面的命令窗口里面,输入命令:mysql -u root -p
回车后提示输入密码。
mysql解压缩版初次安装管理员root的密码为空,因此直接再回车一次就登入mysql数据库了。

如果你不是初次登录mysql,你还拥有网络地址的用户,那么你可以用如下命令登录到mysql服务器,这个mysql服务器也许在远方,也许在本地。这种登录方式叫“远程登录”,命令如下:
mysql -h 192.168.3.143 -u root -p
mysql -h 192.168.3.143 -u root -pleizhimin

-h是指定登录ip,-u指定用户,-p指定密码,-p后如果什么都不写,那么接下来会提示输入密码,-p后也可以直接写上密码,这样就不再需要输入密码了。

6、操作数据库和表
登录mysql数据库后,就可以执行指定操作数据库,用命令:use 数据库名
指定了操作的数据库对象后,就可以操作数据库中的表了,操作方法当然是SQL命令了,呵呵。

7、更改mysql数据库管理员root的密码
mysql数据库中默认有个mysql数据库,这个是mysql系统的数据库,用来保存数据库用户、权限等等很多信息。要更改密码,就要操作mysql数据库的user表。

现在mysql的root用户密码还为空,很不安全的,假设要更改密码为“leizhimin”。

还在上面的命令窗口里面,执行如下命令:
use mysql;
grant all on *.* to root@'%' identified by 'leizhimin' with grant option;
commit;

这段命令的含义是,添加一个root用户,拥有所有的权限,密码为“leizhimin”,并且这个用户不但可以本地访问,也可以通过网络访问。强调这个原因是mysql系统自带的的那个root用户只能从本地访问,它@字符后面的标识是localhost。具体可以查看mysql数据的uer表看看,这样以来,就有两个root用户了,一个是系统原来的,一个新建的,为了管理的方便,就将mysql自带root删除,保留刚创建的这个root用户,原因是这个用户可以通过网络访问mysql。

然后,删除用户的命令:
user mysql;
delete from user where user='root' and host='localhost';
commit;

其实上面的方法是授权命令,在授权的同时创建了数据库用户。mysql也有单独的修改用户密码的方法,下面看看如何操作。
首先,先建立一个用户lavasoft,密码为:123456
grant all on *.* to lavasoft@'localhost' identified by '123456' with grant  option;

接下来就修改这个用户的密码为:leizhimin
update user set password = password('leizhimin') where user = 'lavasoft' and host='localhost';
flush privileges;

说明一点,最好用grant的方式创建mysql用户,尤其对mysql DBA来说,创建用户的同时要指定用户权限,养成好习惯很重要的。

这个修改方法实际上用的是mysql函数来进行的,还有更多的方法,我就不一一介绍了。
还要注意一点就是在修改密码等操作的时候,mysql不允许为表指定别名,但是初次在外却没有这个限制。

8、创建数据库
实际上mysql数据库中除了mysql数据库外,还有一个空的数据库test,供用户测试使用。
现在继续创建一个数据库testdb,并执行一系列sql语句看看mysql数据库的基本操作。

创建数据库testdb:
create database testdb;

预防性创建数据库:
create database if not testdb

创建表:
use testdb;
create table table1(
username varchar(12),
password varchar(20));

预防性创建表aaa:
create table if not exists aaa(ss varchar(20));

查看表结构:
describe table1;

插入数据到表table1:
insert into table1(username,password) values
('leizhimin','lavasoft'),
('hellokitty','hahhahah');
commit;

查询表table1:
select * from table1;

更改数据:

update table1 set password='hehe' where username='hellokitty';
commit;

删除数据:
delete from  table1 where username='hellokitty';
commit;

给表添加一列:
alter table table1 add column(
  sex varchar(2) comment '性别',
  age date not null comment '年龄'
);
commit;

从查询创建一个表table1:
create table tmp as
select * from table1;

删除表table1:
drop table if exists table1;
drop table if exists tmp;

9、备份数据库testdb
mysqldump -h 192.168.3.143 -u root -pleizhimin -x --default-character-set=gbk >C:/testdb.sql

10、删除数据库testdb
drop database testdb;

11、恢复testdb数据库
首先先建立testdb数据库,然后用下面命令进行本地恢复:
mysql -u root -pleizhimin testdb

12、删除mysql服务
假如你厌倦mysql了,你需要卸载,那么你只需要这么做

停止mysql服务
net stop mysql5

删除mysql服务
sc delete mysql5

然后删除msyql的安装文件夹,不留任何痕迹。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What Are the Limitations of Using Views in MySQL?What Are the Limitations of Using Views in MySQL?May 14, 2025 am 12:10 AM

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

Securing Your MySQL Database: Adding Users and Granting PrivilegesSecuring Your MySQL Database: Adding Users and Granting PrivilegesMay 14, 2025 am 12:09 AM

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

What Factors Influence the Number of Triggers I Can Use in MySQL?What Factors Influence the Number of Triggers I Can Use in MySQL?May 14, 2025 am 12:08 AM

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

MySQL: Is it safe to store BLOB?MySQL: Is it safe to store BLOB?May 14, 2025 am 12:07 AM

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

MySQL: Adding a user through a PHP web interfaceMySQL: Adding a user through a PHP web interfaceMay 14, 2025 am 12:04 AM

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),