Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Window detailed process of installing mysql

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "the detailed process of installing mysql in window". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "the detailed process of installing mysql in window".

Environment:

Windows 2000/XP/2003

Mysql-noinstall-5.0.37-win32.zip

1. MySQL

Http://www.mysql.com/downloads

II. Installation process

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

2. Write the running configuration file my.ini of mysql

My.ini

-

[WinMySQLAdmin]

# specify the file to start the mysql service

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 directory where mysql data is stored. It must be data or\ xxxdata.

Datadir=E:\ myserver\-5.0.37-win32\ data

# set the character set of mysql server

Default-character-set=gbk

[client]

# set the character set of mysql client

Default-character-set=gbk

-

3. Install the mysql service

Enter the directory E:myservermysql-5.0.37-win32in from the MS-DOS window and run the following command:

Mysqld-install mysql5-defaults-file= E:myservermysql-5.0.37-win32my.ini

4. Start my

Still in the command window above, enter the command: net start mysql5

This starts the mysql service.

5. Log in to the mysql database locally

Still in the command window above, enter the command: mysql-u root-p

Enter and prompt for your password.

The password of root, the administrator of the first installation of the mysql decompressed version, is empty, so enter directly and log in to the mysql database.

If you are not new to mysql and you have a network address, you can log in to the mysql server, which may be remote or local, with the following command. This login method is called "remote login" and the command is as follows:

Mysql-h 192.168.3.143-u root-p

Mysql-h 192.168.3.143-u root-pleizhimin

-h is the specified login ip,-u specified user,-p specifies the password, if nothing is written after-p, then you will be prompted for a password, or you can write the password directly after-p, so you no longer need to enter the password.

6. Manipulate databases and tables

After logging in to the mysql database, you can perform the specified operation on the database, using the command: use database name

After specifying the database object for the operation, you can manipulate the tables in the database, the operation method is of course the SQL command, hehe.

7. Change the password of mysql database administrator root

There is a mysql database by default in the mysql database, which is the database of the mysql system, which is used to hold database users, permissions, and so on. To change the password, manipulate the user table of the mysql database.

At present, the root user password for mysql is still empty, which is very insecure. Suppose you want to change the password to "leizhimin".

Also in the command window above, execute the following command:

Use mysql

Grant all on *. * to root@% identified by leizhimin with grant option

Commit

The meaning of this command is to add a root user with all privileges with a password of "leizhimin" and that user can access not only locally but also over the network. Emphasize that this reason is that the root user that comes with the mysql system can only be accessed locally, and the identity after the @ character is localhost. Specifically, you can take a look at the uer table of mysql data. Since then, there are two root users, one is the original system, and the other is new. For the convenience of management, delete the mysql with root and retain the root user you just created. The reason is that this 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 the database user at the same time. Mysql also has a separate way to change a user's password. Let's take a look at how to do this.

First, create a user lavasoft with a password of 123456

Grant all on *. * to lavasoft@localhost identified by 123456 with grant option

Then change the user's password to: leizhimin

Update user set password = password (leizhimin) where user = lavasoft and host=localhost

Flush privileges

To illustrate, it is best to use grant to create mysql users, especially for mysql DBA, when creating users, you should specify user permissions, and it is important to form good habits.

This modification is actually done by using the mysql function, and there are more methods that I won't cover one by one.

Also note that mysql does not allow aliases for tables when changing passwords and other operations, but there is no such restriction outside the table for the first time.

8. Create a database

In fact, in addition to the mysql database, there is an empty database test in the mysql database for users to test.

Now continue to create a database testdb and execute a series of sql statements to see the basic operation of the mysql database.

Create the database testdb:

Create database testdb

Preventive creation of the database:

Create database if not testdb

Create a table:

Use testdb

Create table table1 (

Username varchar (12)

Password varchar (20))

Preventive creation table aaa:

Create table if not exists aaa (ss varchar (20))

View the table structure:

Describe table1

Insert data into table table1:

Insert into table1 (username,password) values

(leizhimin,lavasoft)

(hellokitty,hahh)

Commit

Query table table1:

Select * from table1

Change the 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 as

Select * from table1

Delete table table1:

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 database testdb

Drop database testdb

11. Restore testdb database

First set up the testdb database, and then use the following command for local recovery:

Mysql-u root-pleizhimin testdb

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report