Mysql5.1 green version installation tutorial and mysql-related commands (resolving mysqld-nt failure _ MySQL

Source: Internet
Author: User
Mysql5.1 green version installation tutorial and mysql-related commands (resolving mysqld-nt failure) bitsCN.com

Mysql5.1 green version installation tutorial and mysql-related commands (resolving mysqld-nt failure)

But most of the tutorials are still using the mysql-nt Command.

The following describes how to install mysql5.1 decompressed version.

Http://dev.mysql.com/downloads/mirror.php? Id = 414168

The upload chain is mysql-noinstall-5.1.71-win32.zip. for registration, click No thanks, just startmy download. download, decompress it on your D drive, and rename the folder mysql5.1 with the path D:/mysql5.1;

1. set system environment variables and add D:/mysql5.1/bin to Path;

2, according to your own needs to select the configuration file, I only need a small database here, so select the my-small.ini configuration file;

Modify D:/mysql5.1/my-small.ini file content as follows, save as my. ini in the same path.

[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 = 16 K

Max_allowed_packet = 1 M

Table_open_cache = 4

Sort_buffer_size = 64 K

Read_buffer_size = 256 K

Read_rnd_buffer_size = 256 K

Net_buffer_length = 2 K

Thread_stack = 128 K

Basedir = D:/mysql5.1

Datadir = D:/mysql5.1/data

3. run cmd as an administrator.

Enter disk D, and then enter the copy command below:

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

Servicesuccessfully installed is displayed. the installation is successful.

Then open the service window (enter services. msc in the running box to open the service window, and then you can find the mysql service)

4. start the MySQL service

Net start mysql

MySQL service is starting

5. log on to the MySQL server

Mysql-u root-p

Enterpassword: (set the root password by yourself. note: The administrator username of MySQL is root, and the password is blank by default .)

The following is a common mysql command:

1: Use the SHOW statement to find out the current database on the server:

Mysql> show databases;

2. create a database named MYSQLDATA

Mysql> create database mysqldata;

3: Select the database you created

Mysql> use mysqldata; (when you press the Enter key to see Database changed, the operation is successful !)

4: view the tables in the current database

Mysql> show tables;

5. create a database table

Mysql> create table mytable (nameVARCHAR (20), sex CHAR (1 ));

6: Display the table structure:

Mysql> describe mytable;

7. add records to the table

Mysql> insert into MYTABLE values ("shiyuan", "w ");

8: load data into database tables in text mode (for example, D:/mysql.txt)

Mysql> load data local infile "D:/mysql.txt" into table mytable;

9: import the. SQL file command (for example, D:/mysql. SQL)

Mysql> use database;

Mysql> source d:/mysql. SQL;

10: Delete a table

Mysql> drop table mytable;

11: clear the table

Mysql> delete from MYTABLE;

12: update table data

Mysql> update MYTABLE set sex = "m" wherename = 'shiyuan ';

The following are the management experiences of using MySql on the Internet,

In windows, MySql exists as a service. before using mysql, make sure that the service has been started and the net start MySql command is not enabled. In Linux, the "/etc/rc. d/init. d/mysqldstart" command is available. Note that the initiator must have administrator privileges.

The newly installed MySql contains a root account with a blank password and an anonymous account, which poses a major security risk. for some important applications, we should improve the security as much as possible, here, you should delete anonymous accounts and set passwords for root accounts. you can run the following command:

Use mysql;

Delete from User where User = "";

Update User setPassword = PASSWORD ('newpassword') where User = 'root ';

If you want to restrict the logon terminal used by the User, you can update the Host field of the corresponding User in the User table. after making the above changes, restart the database service, at this time, the following commands can be used for logon:

Mysql-u root-p;

Mysql-u root-p newpassword;

Mysql mydb-u root-p;

Mysql mydb-u root-p newpassword;

The preceding command parameters are part of common parameters. for details, refer to the documentation. Here, mydb is the name of the database you want to log on.

In development and practical applications, users should not only use root users to connect to the database. although it is convenient to use root users for testing, it will bring significant security risks to the system, it is not conducive to the improvement of management techniques. We grant the most appropriate Database permissions to the users used in an application. For example, a user who only inserts data should not be granted the permission to delete data. MySql User management is implemented through the User table. There are two common methods to add new users. one is to insert the corresponding data rows in the User table and set the corresponding permissions; the second is to use the GRANT command to create a user with certain permissions. The common usage of GRANT is as follows:

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 ";

To GRANT the user the ability to manage permissions on the corresponding object, you can add the with grantoption option after GRANT. For users inserted into the User table, use the Password function to update and encrypt the PASSWORD field to prevent unauthorized users from stealing the Password. Users who do not need permissions should be cleared, and those who pass the permissions should be revoked in a timely manner. to REVOKE permissions, you can update the corresponding fields in the User table or use the REVOKE operation.

The following is my interpretation of common permissions from other information (www.cn-java.com:

Global management permissions:

FILE: read and write files on the MySQL server.

PROCESS: displays or kills service threads of other users.

RELOAD: RELOAD access control tables and refresh logs.

SHUTDOWN: shut down the MySQL service.

Database/data table/data column permissions:

ALTER: modify existing data tables (such as adding/deleting columns) and indexes.

CREATE: CREATE a new database or data table.

DELETE: DELETE table records.

DROP: Delete a data table or database.

INDEX: create or delete an INDEX.

INSERT: Add table records.

SELECT: Displays/searches for table records.

UPDATE: modify existing records in the table.

Special permissions:

ALL: Allow anything (same as root ).

USAGE: only logon allowed-nothing else is allowed.

BitsCN.com

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.