Home Database Mysql Tutorial mysql5.1绿色版安装教程以及mysql相关命令(解决mysqld-nt不成功_MySQL

mysql5.1绿色版安装教程以及mysql相关命令(解决mysqld-nt不成功_MySQL

Jun 01, 2016 pm 01:30 PM
mysql

bitsCN.com

mysql5.1绿色版安装教程以及mysql相关命令(解决mysqld-nt不成功)

 

看了网上好多mysql5.1绿色版的安装教程都不成功,最后才发现网上的教程都有一个问题,版本太低了,在mysql5.1中已经没有mysqld-nt.exe 这个文件了,而大多数教程还在使用mysql-nt这个命令。

 

下面讲解mysql5.1解压缩版安装过程。

 

http://dev.mysql.com/downloads/mirror.php?id=414168

 

上面链接是mysql-noinstall-5.1.71-win32.zip下载地址,注册不用管直接点下面的No thanks, just startmy download.下载,解压缩在你的D盘,重命名文件夹为mysql5.1 ,路径为D:/mysql5.1;

 

1.设置系统环境变量, 在Path中添加 D:/mysql5.1/bin;

 

2、根据自己的需求选择配置文件,我这里只需要小的数据库,所以选择my-small.ini配置文件;

 

修改D:/mysql5.1/my-small.ini文件内容如下,另存为my.ini在相同路径下。

 

[client]

 

#password      =your_password

 

port        =3306

 

socket            =MySQL

 

default-character-set=utf8

 

# Here follows entries for some specificprograms

 

# The MySQL server

 

[mysqld]

 

port        =3306

 

socket            =MySQL

 

character-set-server=utf8

 

skip-external-locking

 

key_buffer_size = 16K

 

max_allowed_packet = 1M

 

table_open_cache = 4

 

sort_buffer_size = 64K

 

read_buffer_size = 256K

 

read_rnd_buffer_size = 256K

 

net_buffer_length = 2K

 

thread_stack = 128K

 

basedir=D:/mysql5.1

 

datadir=D:/mysql5.1/data

 

3,以管理员身份运行cmd。

 

进入D盘,然后输入复制以下命令:

 

D:/mysql5.1/bin/mysqld -install mysql --defaults-file="D:/mysql5.1/my.ini"

 

出现Servicesuccessfully installed.表示安装成功。

然后打开服务窗口(在运行框中输入services.msc即可打开服务窗口,然后可以找到mysql服务了)

 

4.启动MySQL服务

net start mysql

MySQL服务正在启动 

 

5.登陆MySQL服务器

mysql -u root -p

Enterpassword:(root密码自己设置就好了,注意:MySQL的管理员用户名为root,密码默认为空。)

 

 

 

 

 

下面附上mysql常用命令:

 

1:使用SHOW语句找出在服务器上当前存在什么数据库:

 

mysql> SHOW DATABASES;

 

2:2、创建一个数据库MYSQLDATA

 

mysql> CREATE DATABASE MYSQLDATA;

 

3:选择你所创建的数据库

 

mysql> USE MYSQLDATA; (按回车键出现Database changed 时说明操作成功!)

 

4:查看现在的数据库中存在什么表

 

mysql> SHOW TABLES;

 

5:创建一个数据库表

 

mysql> CREATE TABLE MYTABLE (nameVARCHAR(20), sex CHAR(1));

 

6:显示表的结构:

 

mysql> DESCRIBE MYTABLE;

 

7:往表中加入记录

 

mysql> insert into MYTABLE values(”shiyuan”,”w”);

 

8:用文本方式将数据装入数据库表中(例如D:/mysql.txt)

 

mysql> LOAD DATA LOCAL INFILE“D:/mysql.txt” INTO TABLE MYTABLE;

 

9:导入.sql文件命令(例如D:/mysql.sql)

 

mysql>use database;

 

mysql>source d:/mysql.sql;

 

10:删除表

 

mysql>drop TABLE MYTABLE;

 

11:清空表

 

mysql>delete from MYTABLE;

 

12:更新表中数据

 

mysql>update MYTABLE set sex=”m” wherename=’shiyuan’;

 

 

 

以下是无意中在网络看到的使用MySql的管理心得,

 

在windows中MySql以服务形式存在,在使用前应确保此服务已经启动,未启动可用net start mysql命令启动。而Linux中启动时可用“/etc/rc.d/init.d/mysqldstart”命令,注意启动者应具有管理员权限。

 

刚安装好的MySql包含一个含空密码的root帐户和一个匿名帐户,这是很大的安全隐患,对于一些重要的应用我们应将安全性尽可能提高,在这里应把匿名帐户删除、 root帐户设置密码,可用如下命令进行:

 

use mysql;

 

delete from User where User=”";

 

update User setPassword=PASSWORD(’newpassword’) where User=’root’;

 

如果要对用户所用的登录终端进行限制,可以更新User表中相应用户的Host字段,在进行了以上更改后应重新启动数据库服务,此时登录时可用如下类似命令:

 

mysql -u root -p;

 

mysql -u root -p newpassword;

 

mysql mydb -u root -p;

 

mysql mydb -u root -p newpassword;

 

上面命令参数是常用参数的一部分,详细情况可参考文档。此处的mydb是要登录的数据库的名称。

 

在 进行开发和实际应用中,用户不应该只用root用户进行连接数据库,虽然使用root用户进行测试时很方便,但会给系统带来重大安全隐患,也不利于管理技 术的提高。我们给一个应用中使用的用户赋予最恰当的数据库权限。如一个只进行数据插入的用户不应赋予其删除数据的权限。MySql的用户管理是通过 User表来实现的,添加新用户常用的方法有两个,一是在User表插入相应的数据行,同时设置相应的权限;二是通过GRANT命令创建具有某种权限的用 户。其中GRANT的常用用法如下:

 

grant all on mydb.* to NewUserName@HostNameidentified by “password” ;

 

grant usage on *.* to NewUserName@HostNameidentified by “password”;

 

grant select,insert,update on mydb.* toNewUserName@HostName identified by “password”;

 

grant update,delete on mydb.TestTable toNewUserName@HostName identified by “password”;

 

若 要给此用户赋予他在相应对象上的权限的管理能力,可在GRANT后面添加WITH GRANTOPTION选项。而对于用插入User表添加的用户,Password字段应用PASSWORD 函数进行更新加密,以防不轨之人窃看密码。对于那些已经不用的用户应给予清除,权限过界的用户应及时回收权限,回收权限可以通过更新User表相应字段, 也可以使用REVOKE操作。

 

下面给出本人从其它资料(www.cn-java.com)获得的对常用权限的解释:

 

全局管理权限:

 

FILE: 在MySQL服务器上读写文件。

 

PROCESS: 显示或杀死属于其它用户的服务线程。

 

RELOAD: 重载访问控制表,刷新日志等。

 

SHUTDOWN: 关闭MySQL服务。

 

数据库/数据表/数据列权限:

 

ALTER: 修改已存在的数据表(例如增加/删除列)和索引。

 

CREATE: 建立新的数据库或数据表。

 

DELETE: 删除表的记录。

 

DROP: 删除数据表或数据库。

 

INDEX: 建立或删除索引。

 

INSERT: 增加表的记录。

 

SELECT: 显示/搜索表的记录。

 

UPDATE: 修改表中已存在的记录。

 

特别的权限:

 

ALL: 允许做任何事(和root一样)。

 

USAGE: 只允许登录–其它什么也不允许做。

bitsCN.com
Statement of this Website
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

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP's big data structure processing skills PHP's big data structure processing skills May 08, 2024 am 10:24 AM

Big data structure processing skills: Chunking: Break down the data set and process it in chunks to reduce memory consumption. Generator: Generate data items one by one without loading the entire data set, suitable for unlimited data sets. Streaming: Read files or query results line by line, suitable for large files or remote data. External storage: For very large data sets, store the data in a database or NoSQL.

How to optimize MySQL query performance in PHP? How to optimize MySQL query performance in PHP? Jun 03, 2024 pm 08:11 PM

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How to insert data into a MySQL table using PHP? How to insert data into a MySQL table using PHP? Jun 02, 2024 pm 02:26 PM

How to insert data into MySQL table? Connect to the database: Use mysqli to establish a connection to the database. Prepare the SQL query: Write an INSERT statement to specify the columns and values ​​to be inserted. Execute query: Use the query() method to execute the insertion query. If successful, a confirmation message will be output.

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

How to use MySQL stored procedures in PHP? How to use MySQL stored procedures in PHP? Jun 02, 2024 pm 02:13 PM

To use MySQL stored procedures in PHP: Use PDO or the MySQLi extension to connect to a MySQL database. Prepare the statement to call the stored procedure. Execute the stored procedure. Process the result set (if the stored procedure returns results). Close the database connection.

How to create a MySQL table using PHP? How to create a MySQL table using PHP? Jun 04, 2024 pm 01:57 PM

Creating a MySQL table using PHP requires the following steps: Connect to the database. Create the database if it does not exist. Select a database. Create table. Execute the query. Close the connection.

The difference between oracle database and mysql The difference between oracle database and mysql May 10, 2024 am 01:54 AM

Oracle database and MySQL are both databases based on the relational model, but Oracle is superior in terms of compatibility, scalability, data types and security; while MySQL focuses on speed and flexibility and is more suitable for small to medium-sized data sets. . ① Oracle provides a wide range of data types, ② provides advanced security features, ③ is suitable for enterprise-level applications; ① MySQL supports NoSQL data types, ② has fewer security measures, and ③ is suitable for small to medium-sized applications.

See all articles