Windows install mysql (zip and noinstall)

Source: Internet
Author: User
Tags mysql functions

Core tips: This article summarizes the mysql-noinstall version, that is, the installation and configuration application of the decompressed version. These operations are commonly used. The article does not describe the executable installation version of mysql. the executable installation version has many drawbacks.
This article summarizes the mysql-noinstall version, that is, the installation and configuration application of the decompressed version. These operations are commonly used. The article does not describe the executable installation version of mysql. the executable installation version has many drawbacks. In short, I like green products, including eclipse, tomcat, jboss, and apache. Even if the operating system is reinstalled, these software does not need to be reinstalled!

Environment:
Windows 2000/XP/2003
Mysql-noinstall-5.0.37-win32.zip

1. Download MySQL

Http://www.mysql.com/downloads

Ii. Installation Process

1. Decompress mysql-noinstall-5.0.37-win32.zip to a directory and add it to the E: myserver directory.

2. Compile the mysql running configuration file my. ini.
My. ini
-----------------------------
[WinMySQLAdmin]
# Specify the mysql Service Startup File
Server = E: \ myserver \ mysql-5.0.37-win32 \ bin \ mysqld-nt.exe

[Mysqld]
# Set the installation directory of mysql
Basedir = E: \ myserver \ mysql-5.0.37-win32
# Set the data storage directory of the mysql database, which must be data or \ xxxdata
Datadir = E: \ myserver \ mysql-5.0.37-win32 \ data
# Set the character set of the mysql server
Default-character-set = gbk

[Client]
# Set the character set of the mysql client
Default-character-set = gbk
-----------------------------

3. Install the mysql Service
Enter directory E: MS-DOS from the myservermysql-5.0.37-win32in window and run the following command:
Mysqld -- install mysql5 -- defaults-file = E: myservermysql-5.0.37-win32my.ini

4. Start the mysql database
In the above command window, enter the command: net start mysql5
In this way, the mysql service is started.

5. (local) log on to the mysql database
In the preceding command window, run mysql-u root-p.
Enter the password.
The password for the first installation of the mysql decompress version administrator root is blank, so you can directly press enter to log on to the mysql database.

If you are not logging on to mysql for the first time and you still have a network address, you can use the following command to log on to the mysql server, which may be far away or local. This logon method is called "remote Logon". The command is as follows:
Mysql-h 192.168.3.143-u root-p
Mysql-h 192.168.3.143-u root-pleizhimin

-H indicates the logon ip address,-u indicates the user, and-p specifies the password. If no password is written after-p, the system will prompt you to enter the password, -p can also be used to directly write the password, so that you no longer need to enter the password.

6. operate databases and tables
After logging on to the mysql database, you can run the command: use Database Name
After specifying the database object for operation, you can operate the tables in the database. The operation method is of course an SQL command.

7. change the password of the mysql database administrator root.
Mysql database has a mysql database by default, which is a mysql System database used to save a lot of information such as database users and permissions. To change the password, you must operate the mysql database user table.

The password of the root user in mysql is still empty, which is very insecure. Assume that you want to change the password to "leizhimin ".

In the preceding command window, run the following command:
Use mysql;
Grant all on *. * to root @ % identified by leizhimin with grant option;
Commit;

This command adds a root user with all permissions. The password is "leizhimin", which can be accessed locally or through the network. It is emphasized that the root user of the mysql system can only access the database locally. Its @ character is followed by localhost. For details, you can view the uer table of mysql Data. In this way, there are two root users, one is the original system, and the other is newly created, for the convenience of management, delete the mysql root User and keep the created root user because the user can access mysql through the network.

Then, delete the user's command:
User mysql;
Delete from user where user = root and host = localhost;
Commit;

In fact, the above method is the authorization command, which creates a database user while authorizing. Mysql also has a separate way to change the user password. Let's take a look at how to perform this operation.
First, create a user lavasoft with a password of 123456.
Grant all on *. * to lavasoft @ localhost identified by 123456 with grant option;

Next, change the password of this user to leizhimin.
Update user set password = password (leizhimin) where user = lavasoft and host = localhost;
Flush privileges;

Note: it is best to create a mysql user using grant. Especially for mysql DBA, it is important to specify user permissions when creating a user.

This modification method is actually implemented using mysql functions. I will not introduce it one by one.
Note that mysql does not allow you to specify an alias for a table during password modification or other operations, but does not have this restriction for the first time.

8. Create a database
In fact, in addition to the mysql database, the mysql database also has an empty database test for testing.
Create a database testdb and execute a series of SQL statements to view the basic operations of the mysql database.

Create a database testdb:
Create database testdb;

Preventive database creation:
Create database if not testdb

Create a table:
Use testdb;
Create table table1 (
Username varchar (12 ),
Password varchar (20 ));

Preventive table creation aaa:
Create table if not exists aaa (ss varchar (20 ));

View the table structure:
Describe table1;

Insert data to table 1:
Insert into table1 (username, password) values
(Leizhimin, lavasoft ),
(Hellokitty, hahhahah );
Commit;

Query table 1:
Select * from table1;

Change Data:

Update table1 set password = hehe where username = hellokitty;
Commit;

Delete data:
Delete from table1 where username = hellokitty;
Commit;

Add a column to the table:
Alter table table1 add column (
Sex varchar (2) comment gender,
Age date not null comment age
);
Commit;

Create a table table1 from the query:
Create table tmp
Select * from table1;

Delete table 1:
Drop table if exists table1;
Drop table if exists tmp;

9. Back up the database testdb
Mysqldump-h 192.168.3.143-u root-pleizhimin-x -- default-character-set = gbk> C: estdb. SQL

10. Delete the database testdb
Drop database testdb;

11. Restore the testdb Database
First, create the testdb database, and then use the following command to perform local recovery:
Mysql-u root-pleizhimin testdb <C: estdb. SQL

12. Delete the mysql Service
If you are tired of mysql and need to uninstall it, you only need to do so.

Stop mysql Service
Net stop mysql5

Delete mysql Service
SC delete mysql5

Mysqld-nt -- remove

Delete the msyql installation folder without any trace.


The MySQL server can run as either a foreground service or a background service. The following MySQL service programs are provided in the bin directory of the MySQL installation directory:

Mysqld.exe: the most basic MySQL server program.

Mysqld-nt.exe: optimized for Windows NT/2000/XP platforms, supports named pipelines.
 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.