Mysql Installation-free version of the actual configuration method _mysql

Source: Internet
Author: User
Tags create index mysql free mysql host mysql in table name win32 import database mysql command line
The following article is mainly about MySQL-free installation version of the actual configuration method, its free installation version can be downloaded in the relevant web site, download can be extracted to C:\MySQL to obtain his arbitrary location, after decompression in the directory, find My-huge.ini,my-large.ini, My-medium.ini configuration file.

Open for configuration:

Copy Code code as follows:

[MySQLd]
# set Basedir to your installation path
Basedir=c:/mysql
# set DataDir to the location of your data directory
Datadir=c:/mydata/data

MySQL free installation version of the configuration method we need to set the MySQL character set, GBK or utf-8, according to

Copy Code code as follows:

# Set Character Set
Default-character-set=gbk
# Set Character collation
Default-collation=gbk_chinese_ci

Save As My.ini after saving

Finally in the beginning-> run

Copy Code code as follows:

c:\mysql\bin\> MySQLd--install MySQL--defaults-file=c:\my.ini
c:\mysql\bin\> NET START MySQL

OK, default account root, password empty.


The above related content is to MySQL installation version of the configuration method of introduction, hope you can have some harvest.

The following are the references of other netizens:
Taking mysql-noinstall-5.1.6 (Win32) as an example

1> the compressed file mysql-noinstall-5.1.6-alpha-win32.zip to a directory, set the Mysql_home in the environment variable, add the%mysql_home%\bin

Into path.

2> creates the My.ini configuration file, which reads as follows:

[Mysqld]
#设置basedir指向mysql的安装路径
Basedir=...\mysql
Datadir=...\mysql\data

My.ini files are placed under System files
XP system in the C:\windows directory, 2000 system under C:\WINNT

3> start and stop MySQL

Mysqld-nt.exe--install (Install Windows service, uninstall using Mysqld-nt.exe--remove)
Start: net start MySQL
Stop: net stop MySQL

4> connection MySQL
Format: mysql-h host address-u user name-P user Password
Example 1: MySQL connected to this computer
Mysql-uroot-p
Example 2: Connecting to MySQL on a remote host
Mysql-h110.110.110.110-uroot-pabcd123

5> exit MySQL Command
Exit (Enter)
Or
Quit (carriage return)

6> Modify Password
Format: Mysqladmin-u username-P Old password password new password
Example: Add a password ab12 to root. First enter the directory Mysqlbin in DOS, and then type the following command
Mysqladmin-uroot Password AB12
Note: Since Root does not have a password at the beginning, the-p old password can be omitted.
2, Example 2: Then the root password changed to djg345.
MYSQLADMIN-UROOT-PAB12 Password djg345

The following is a command in the MySQL environment, with a semicolon as the command terminator

7> Add new users
Format: Grant Select on database. * To User name @ login host identified by "password";

Example 1, add a user test1 password to ABC, so that he can log on any host, and all databases have
Permissions to query, insert, modify, and delete. First connect the root user to MySQL, and then type the following command:
Grant Select,insert,update,delete on *.* to test1@ "%" identified by "ABC";

Example 2, add a user test2 password to ABC, so that it can only log on localhost, and can be on the database
MyDB to query, insert, modify, delete operations (localhost refers to the local host, that is, MySQL data
The host on which the library resides, so that the user can use a password that knows test2, and cannot direct from the Internet
Access to the database can only be accessed through a Web page on the MySQL host.
Grant Select,insert,update,delete on mydb.* to Test2@localhost identified by "ABC";

8> Display list of databases
show databases;

9> display data tables in the library
Use mysql;//database name
Show tables;

10> display the structure of a datasheet
describe table name;

11> Build a library
Create database library name;

12> Building Table
Use library name;
CREATE TABLE table name (field set list);

13> Deleting and deleting tables
drop Database library name;
The drop table table name;

14> the records in the table empty
Delete from table name;

15> display records in a table
SELECT * from table name;

Cases:
Drop database if exists school; Delete if there is school
Create Database School; Build a library School
Use school; Open Library School
CREATE TABLE teacher//Create tables Teacher
(
ID int (3) auto_increment NOT null primary key,
Name Char (a) NOT NULL,
Address varchar default ' Shenzhen ',
Year Date
); Build Table End
The following is the Insert field
Insert into teacher values (', ' Glchengang ', ' Shenzhen One ', ' 1976-10-10 ');
Insert into teacher values (', ' Jack ', ' Shenzhen One ', ' 1975-12-23 ');

Note: In the construction of the table
(1) Set the ID to a number field of length 3: Int (3), and let it automatically add one for each record: Auto_increment,
cannot be null: NOT NULL, and make it the primary field primary key
(2) Set name to a character field of length 10
(3) Set the address to a character field of length 50 and the default value is Shenzhen. What's the difference between varchar and char?
, only wait for later articles to say.
(4) Set year as Date field.
If you type the above command at the MySQL prompt, it's not easy to debug. You can use the above command
Write-as-is in a text file assumed to be school.sql, then copied to C: Under, and enter the directory in DOS state
MySQL in, and then type the following command:
Mysql-uroot-p Password < C:school.sql
If successful, there is no display on a single line, and if there is an error, there is a hint. (The above command has been debugged and you
As long as the//comments are removed to use.

16> transfer text data to a database
1, the text data should conform to the format: The field data is separated by the TAB key, null value is used instead. Cases:
3 Rose Shenzhen II 1976-10-10
4 Mike Shenzhen one 1975-12-23
2, Data incoming command load infile "filename" into table name;
Note: You'd better copy the files to the MySQL in directory and use the Using command first? 硭  狻?/p>

17> Export and import data
1. Export table
Mysqldump--opt School > School.sql
Note: Back up all the tables in the database school to the School.sql file, School.sql is a text file,
File name, open and see what you'll find.
Mysqldump--opt school teacher student > School.teacher.student.sql
Note: Back up teacher tables and student tables in the database school to School.teacher.student.sql
Pieces, School.teacher.student.sql is a text file, file name to take, open look you will have new discoveries.

2. Import Table
Mysql
Mysql>create Database School;
Mysql>use School;
Mysql>source School.sql;
(or change the school.sql to School.teacher.sql/school.teacher.student.sql)

3. Export Database
Mysqldump--databases db1 DB2 > Db1.db2.sql
Note: Back up the database Dbl and DB2 to the Db1.db2.sql file, Db1.db2.sql is a text file, file name
Let's open and see what you'll find.
(For an example:
Mysqldump-h host-u user-p pass--databases dbname > File.dump
Is the host on the name user, password pass database dbname Import into the file file.dump. )

4. Import Database
MySQL < Db1.db2.sql

5. Copy Database
Mysqldump--all-databases > All-databases.sql
Note: Back up all the databases to the All-databases.sql file, All-databases.sql is a text file,
The file name is either taken.

6. Import Database
Mysql
Mysql>drop database A;
Mysql>drop database B;
Mysql>drop database C;
...
Mysql>source All-databases.sql; (or exit MySQL after MySQL < all-databases.sql)

18> creates a complete superuser who can connect to the server from anywhere, but must use a password something do this
Grant all privileges on *.* to monty@ "%" identified by ' something ' with GRANT OPTION;

19> Delete Authorization
REVOKE all privileges to *.* from root@ "%";
Use MySQL;
DELETE from user WHERE user= "root" and host= "%";
FLUSH privileges;

20> Create a user named Weiqiong.com Log on to a specific client to access a specific database BankAccount
Mysql> GRANT Select,insert,update,delete,create,drop on bankaccount.*
To custom@weiqiong.com identified by ' stupid ';

21> Renaming tables
ALTER TABLE T1 RENAME T2;

22> Change Column
In order to change column A, change from integer to tinyint not NULL (same as name),
and change column B, changing from char (10) to char (20), renaming it at the same time, change from B to C:
ALTER TABLE T2 MODIFY a TINYINT not NULL and change B C CHAR (20);

23> Add Column
Add a new timestamp column, named D:
ALTER TABLE T2 ADD D TIMESTAMP;

24> adds an index to column D and makes column a the primary key
ALTER TABLE T2 Add INDEX (d), add PRIMARY KEY (a);

25> Delete Columns
ALTER TABLE T2 DROP COLUMN C;

26> Delete Records
DELETE from T1 WHERE c>10;

27> Change a few lines
UPDATE T1 SET User=weiqiong,password=weiqiong;

28> CREATE Index
Create an index using the first 10 characters of the Name column:
CREATE INDEX part_of_name on customer (name (10));

29> set MySQL Chinese character set (MySQL normal display Chinese)

1, configure the server side, modify the My.ini file, use the Chinese character set to store records, and use the Chinese sort comparison method.
[Mysqld]
# Set Character Set
Default-character-set=gbk
# Set Character collation
Default-collation=gbk_chinese_ci

2. If you want to use the MySQL command line on the server side of the Chinese environment, change the default character set of MySQL in the My.ini file.
[MySQL]
# Set Character Set
Default-character-set=gbk

In addition, it is recommended that a Chinese-compatible graphical interface tool Navicat.

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.