Use database google cloud mysql - mysql

Hi I am new mysql and Google cloud SQL. I created a database and now can't seem to use it. Please see the list of commands below which leads to the error
Google SQL Client
Type "help" or "?" for help.
Connecting to Google SQL database "evident-castle-346:pocsql01" on host None.
Using readline for history management.
Loading history file "/Users/*********/.googlesql/evident-castle-346#pocsql01.hist"
sql> show database
Database: evident-castle-346:pocsql01
Vendor: MySQL AB
Product: MySQL
Version: 5.5.34
sql> use evident-castle-346:pocsql01;
ERROR:google_sql:(1064, u"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 '-castle 346:pocsql01' at line 1")
sql>
I can't seem to figure out what the error in my syntax is.
Please help

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

Sql Syntax error with Doctrine, probably because of change of Mysql version

I've programmed a project in symfony and mysql 5.6. then I uploaded my project to a remote server on 1&1. the remote server has mysql 5.7 version. All doctrine queries run ok and without problem. But when a user searches something, a request will be sent to the server and a doctrine query will be executed. Here it returns the following error:
SQLSTATE[42000]: Syntax error or access violation: 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 'integer)
BETWEEN 1940 AND 2002) AND u0_.id <> 2' at line 1
I think, it is probably because of different versions of mysql. Because on localhost it runs without problem
Can you please help me how to solve it? is there a way to regenerate all the migrations according the new mysql version? or may be there is another solution?
thanks
I was using CAST('number' as integer) in mysql 5.6. It did ok. However in mysql 5.7 and I do not know why, it does not run ok. So I changed it to CAST('number' as UNSIGNED) and it works ok

'Syntax Error' when using Database Navigator for PyCharm

I have a project with a MySQL database to which I connected using the Database Navigator plugin.
Now when I open the DB Browser window, select the database and click on "Open DB console" and insert the query
SELECT CAST('2017-08-29' AS DATE);
for one, the IDE highlights CAST as an unknown identifier:
and, additionally, when I try to execute the statement, I get the error
Error executing SELECT statement. 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 '' at line 1 - Connection: test: 112ms
However, to my knowledge, this is valid MySQL, at least this page suggests so.
I am also able to perform MySQL queries with casts from a python script that builds the connection itself.
What am I doing wrong here? Do I have to configure the dialect for Database Navigator?

How to find the file causing a mysql syntax error

I'm a newbie. I just set up Ubuntu to run on my Chromebook (via Crouton) last week and am currently in the process of setting up several Wordpress sites on localhost. I successfully installed a new Wordpress site yesterday, and I'm able to access the frontend and backend of the site via localhost no problem.
Today I wanted to create another Wordpress site. But when I try to create a new database in mysql using Terminal, I get the following error:
mysql> CREATE DATABASE;
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 '' at line 1
How do I figure out which file is causing the syntax error? I checked php.ini, which I edited yesterday, but line 1 looks fine.
The right way to use Mysql CREATE DATABASE statement
CREATE DATABASE my_db;
To my belief, you are missing the database name:
mysql>CREATE DATABASE database_name;

Parameterize MySQL workbench statements: How to define variables

I'm trying to parameterize a set of frequently used queries in my workbench.
This works:
select * from providers where id='112233';
This
WbVarDef var1=112233;
select * from providers where id='$[var1]';
gives error
Error Code: 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 'from providers where id='112233'' at line 1
My reference was this.
Just to be clear, these are in the MySQL workbench and not a workbench script file or a mysql script file.
In MySQL, syntax for setting variable is below.
SET #var1 = '112233';
and using the variable would be as below.
select * from providers where id=#var1;
Check out MySQL documentation for more information Link to MySQL Documentation
Based on your tag mysql-workbench, I find it simply to be a case where the referenced documentation and use is not relevant to what you are using.
Back up the hierarchy from your link to this http://www.sql-workbench.net/
and you will read:
Please note that SQL Workbench/J has no relation to the product MySQL
Workbench which is maintained and owned by Oracle. If you
are looking for MySQL Workbench support please contact Oracle.