Go to window to install MySQL (zip and noinstall)

Source: Internet
Author: User
Tags mysql functions win32 window

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 \ XXX \ data
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 the directory e: \ myserver \ MS-DOS \ bin from the mysql-5.0.37-win32 window and run the following command:
Mysqld -- install mysql5 -- defaults-file = E: \ myserver \ mysql-5.0.37-win32 \ My. 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 '000000' with grant option;

Next, change the password of this user to leizhimin.
Update user SET Password = PASSWORD ('leizhimin') where user = 'lavasosft '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 = 'hei' 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: \ testdb. 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: \ testdb. 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.