国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 PHP開發(fā) Problems and solutions encountered when mysql exports select statement results to excel files

Problems and solutions encountered when mysql exports select statement results to excel files

Jan 03, 2017 pm 04:40 PM

1. Export data external

1) mysql connection + output the query results to a file. Execute in the command line (cmd command line of windows, terminal of mac)

mysql -hxx -uxx -pxx -e "query statement" db > file

 -h: followed by the linked host (host)

-u: What follows is the username

-p: What follows is the password

db: The database you want to query

File: The file you want to write, absolute path

For example:

The following is the query result of the sql statement select * from edu_iclass_areas The output is output to the file /Users/zhengcanrui/WORK/test/test.xls.

mysql -h127.0.0.1 -uroot -p123 -e "select * from edu_iclass_areas" test > /Users/zhengcanrui/WORK/test/test.xls

2) Mysql connection and output of query results to the database are executed separately

mysql -hxxx -uxx -pxx
select * from table into outfile 'xxx.txt';

The contents of the -h/-u/-p parameters are the same as above. xxx.txt is the file path and name to be output.

Such as:

-- 登錄mysql
mysql -h127.0.0.1 -uroot -p123
-- 將查詢結(jié)果輸出到文件中
select * from edu_iclass_areas into outfile /Users/zhengcanrui/WORK/test/test.xls

The above two execution effects are equivalent.

2. Problems encountered

1. Mac starts the mysql command in the terminal

1) After installing the MySQL service ( For installation steps, please refer to series of experience 1). Open "System Preferences" and click the "MySQL" icon at the bottom.

mysql 導(dǎo)出select語句結(jié)果到excel文件遇到問題及解決方法

2) In the "MySQL" dialog box, click the "Start MySQL Service" button

mysql 導(dǎo)出select語句結(jié)果到excel文件遇到問題及解決方法

3) Click Applications in Finder's sidebar, and then in Utilities, double-click to launch the Terminal command.

4) Enter the command to add the MySQL path in the terminal:

PATH="$PATH":/usr/local/mysql/bin

5) The command to log in to MySQL in the terminal is as follows:

mysql -u root -p

mysql 導(dǎo)出select語句結(jié)果到excel文件遇到問題及解決方法


#2. Access denied for user 'mysql username'@'host or IP' (using password: YES)'


Cause:


MySQL's permissions have not been released to access localhost.


You can use the following command to release permissions (authorization):


First enter the mysql client command line.


Then enter:


1: You want to connect to the mysql server from any host using the mysql username myuser and use mypassword as the password

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
flush privileges;

2: You want to use the mysql username myuser to connect to the mysql server from the host with ip 192.168.1.3, and use mypassword as the password

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
flush privileges;

Just execute these two commands.


The above is the problem and solution encountered by mysql exporting select statement results to excel files introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message. , the editor will reply to everyone in time. I would also like to thank you all for your support of the PHP Chinese website!

For more mysql export select statement results to excel files and related articles about problems and solutions, please pay attention to the PHP Chinese website!


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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)