Home > Database > Mysql Tutorial > body text

How to attach database in mysql

coldplay.xixi
Release: 2020-10-19 11:00:55
Original
6082 people have browsed it

How to attach a database in mysql: 1. Open [Desktop-My Computer-Properties-Environment Variables] and create a new path [PATH=";,path\mysql\bin;"]; 2. Export the database file from the database, the code is [c:\>mysqldump -h localhost ..].

How to attach database in mysql

Related learning free recommendations: mysql database( Video)

How to attach a database in mysql:

1. MYSQL command line mode settings:

Desktop->My Computer->Properties->Environment Variables->New->

PATH=";,path\mysql\bin;" where path is MYSQL installation path.

2. Briefly introduce the method of entering MYSQL from the command line:

1. C:\>mysql -h hostname -u username -p

Press ENTER, wait and then enter the password. Here hostname is the name of the server, such as localhost, and username is the MYSQL user name, such as root.

After entering the command line, you can directly operate MYSQL.

2. Briefly introduce the MYSQL command:

mysql->CREATE DATABASE dbname;//创建数据库
mysql->CREATE TABLE tablename;//创建表
mysql->SHOW DATABASES;//显示数据库信息,有那些可用的数据库。
mysql->USE dbname;//选择数据库
mysql->SHOW TABLES;//显示表信息,有那些可用的表
mysql->DESCRIBE tablename;//显示创建的表的信息
Copy after login

3. Export the database file from the database:

1. Export the database mydb to e: \mysql\mydb.sql file:

Open Start->Run->Enter cmd to enter the command line mode

c:\>mysqldump -h localhost -u root -p mydb >e:\mysql\mydb.sql
Copy after login

Then enter the password, wait for a while and the export will be successful. OK Go to the target file to check whether it is successful.

2. Export the mytable in the database mydb to the e:\mysql\mytable.sql file:

c:\>mysqldump -h localhost -u root -p mydb mytable>e:\mysql\mytable.sql
Copy after login

3. Export the structure of the database mydb to e:\mysql\mydb_stru. sql file:

c:\>mysqldump -h localhost -u root -p mydb --add-drop-table >e:\mysql\mydb_stru.sql
Copy after login

4. Import data from an external file into the database:

Copy the SQL statement in the file from e:\mysql\mydb2.sql Import into the database:

1. Enter mysql from the command line, and then use the command CREATE DATABASE mydb2; to create the database mydb2.

2. To exit mysql, you can enter the command exit; or quit;

3. Enter the following command in CMD:

c:\>mysql -h localhost -u root -p mydb2 < e:\mysql\mydb2.sql
Copy after login

Then enter the password, and it is OK.

5. Let’s talk about the solution to the problem of import file size limit:

By default: mysql has a limit on the import file size, the maximum is 2M, so When the file is very large, it cannot be imported directly. The solutions to this problem are listed below:

1. Modify the relevant parameters in php.ini:

There are three parameters that affect the size of the mysql imported file. Numbers:

  • memory_limit=128M,

  • upload_max_filesize=2M,

  • ##post_max_size=8M

Modify upload_max_filesize=200 M Here modify the size that meets your needs,

You can modify the other two items at the same time

memory_limit=250M, post_max_size =200M

In this way,

.sql files under 200M can be imported.

The above is the detailed content of How to attach database in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template