MySQL LOAD XML LOCAL INFILE - mysql

I'm building an application on my local machine, and for the longest time, was using Windows 7 with MySQL installed, but as I've now moved onto Linux, I'm trying to execute this statement:
LOAD XML LOCAL INFILE 'http://example.com/tech.xml'
INTO TABLE t
ROWS IDENTIFIED BY '<product>';
This is not working, and I do have all the privileges necessary in order to accomplish this.
How can I make this statement work?
When I was using Windows (r) the statement would work perfectly. Where do I put the file on my web server if I want to access it via MySQL?
I get this error:
Error Code: 1064. You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right
syntax to use near 'XML LOCAL INFILE 'http://example.com/tech.xml'
INTO TABLE t
ROWS IDENTIFIE' at line 1

LOAD XML INFILE is available from mySQL 5.2 and higher.
You probably have an older version than that.

Related

Error code: 1064 in MySQL when create SOURCE?

I want to use my SQL'book_data2' file from the desktop E drive as a 'SOURCE'. But I am getting an error code 1064 in MySQL workbench. Could you help me for that issue? I am giving the code and action output below.
Code:
SOURCE E:\DataPractice\Practice\book_data2.sql;
Action Output:
Error Code: 1064. You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'SOURCE E:\DataPractice\Practice\book_data2.sql' at
line 1 0.000 sec
There are a number of commands that are supported by the mysql client (that is, the command-line client, not MySQL Workbench), but they are parsed in the client, not sent to the server as SQL statements. The MySQL Server does not recognize these commands.
It can be confusing, but remember both the client and the server may process commands. You just have to read the documentation to learn which commands are in the list of client-only commands:
https://dev.mysql.com/doc/refman/8.0/en/mysql-commands.html
(Except USE, which is recognized by both mysql client and server, just to make sure there's an exception to every rule!)
If you want to use MySQL Workbench to "source" an SQL file, in other words load a file, read the SQL commands in that file, and execute them, Workbench does support this action, but they call it Data Import/Restore. It's documented here: https://dev.mysql.com/doc/workbench/en/wb-admin-export-import-management.html

Why select json data not working in the mariadb?

My query like this :
select `information`->'$."full_name"' as `homeroom`
from `classes`
If the query run in my database local, it works. No error
But if the query run in my database server, it does not works. There exist error like this :
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '>'$."full_name"' as `homeroom`
from `classes` LIMIT 0, 25' at line 1
If I run select version(),
My version database local : 8.0.15
My version database server : 10.0.38-MariaDB
Seems it does not work because my database server using mariadb
How can I solve this problem?
Update :
I using data type text to infomation field
JSON functions weren't added to MariaDB until version 10.2.3. If you can't upgrade you will have to process the data in your application. Note that even in versions that support JSON, they don't support the -> notation (reference) so you will have to rewrite the query as
JSON_EXTRACT(information, '$.full_name')

How to bulk insert a csv file?

BULK INSERT krissmall
FROM 'C:\Users\Administrator\Downloads\misskrisdata_small.csv'
WITH (FIELDTERMINATOR = ',', ROWTERMINATOR = '\n')
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'BULK
INSERT krissmall FROM 'C:\Users\Administrator\Downloads\misskrisdata_small.' at
line 1
Can someone please tell me where went wrong? Or some other reasons behind this. I stared at this query for a long time, and looked it up a lot but I cannot find where it is wrong.
I'm curious where you looked up BULK INSERT since that doesn't seem to be supported by MySQL at all. Maybe you're reading MS SQL documentation and confusing the two.
What you want is LOAD DATA INFILE which can parse CSV.
You tagged phpmyadmin which leads me to believe that you are trying to execute this query from a remote server (possibly a web host). The remote server can't connect to your local drive. You must import through phpMyAdmin or upload the file you wish to import to a directory that phpMyAdmin can see.

OpenCart on Windows XP Error

I'm trying to install Open Cart on my virtual machine with, PHP 5.4.7, MySQL 5.5 and Apache 2.2. After A LOT of troubles, I've managed to arrive at the moment of installation script execution, but I receive this problem:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/*!40101 SET #OLD_CHARACTER_SET_CLIENT=##CHARACTER_SET_CLIENT */' at line 1
Honestly I'm stuck. I've tried to execute the code in Workbench and it works, except that in the INSERT INTO queries for test data they've missed default values for NOT NULL columns.
Hints? Suggestion?
Those random characters at the start of the SQL are the UTF Byte Order Mark. Something you used to edit the file decided to emit that at the start. Quickest way to get rid of it would be getting Notepad++, open the file in that, Select "Encoding->Enocde in UTF-8 without BOM", and resave the file, and try again.

Import multiple large sql dump mysql

I want to import several .sql files into database using source command (mysql command line). But when I get this error:
source E:\Progs\Backups\DBs\file01.sql
ERROR:
Unknown command '\P'.
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'sourc
e E:\Progs' at line 1
....
I used source command to import large files hundreds times but now I can not understand what I'm doing wrong. This is my system(I'm using XAMPP (Basis Package) version 1.7.3 :
Windows 7x64
MySQL 5.1.41 (Community Server) with PBXT engine 1.0.09-rc
Any help would be appreciated.
Thanks!
Edit:
I tried this one, but same error:
source 'E:\Progs\Backups\DBs\file01.sql'
MySQL sees the \P in E:\Progs as a command. Because that command does not exist, it complains.
Forward slashes are understood in many cases. Try:
source E:/Progs/Backups/DBs/file01.sql