Error when switching user in mysql client - mysql

When trying to switch to another user from root I am getting the below error. But most of the examples show this is right syntax. Could you please help me?
Error:
You have an error in SQL syntax; check the manual that corresponds to your mysql version for the right syntax to use near 'mysql -u bcs_fms -p'

You have to execute this command from CLI, not from the mysql console.

Related

Create database in SQL and get an error but everything right

I try to install fleetspeak. Use Ubuntu 18.04.
First of all I run this
CREATE USER 'fleetspeak-user' IDENTIFIED BY 'fleetspeak-password';
Then I want to create database with this
CREATE DATABASE 'fleetspeak';
But has an error:
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 ''fleetspeak'' at line 1
Why I can get this?
Try the create database script without single quotes in dbname
CREATE DATABASE fleetspeak;

Backwards compatible mysql dump

I am trying to port a database from mysql 5.7 to mysql 5.5.
At first, I used the following command
mysqldump -u root -p --all-databases > alldbs.sql
When I try to import the DB in mysql 5.5 I keep getting errors like
ERROR 1064 (42000) at line 572: 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 'STATS_PERSISTENT=0' at line 9
where it complains about STATS_PERSISTENT=0 statement.
Then I tried
mysqldump -u root -p --compatible=mysql40 --all-databases > alldbs.sql
but this just gives me
ERROR 1064 (42000) at line 26: 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 'TYPE=InnoDB' at line 22
where it complains about TYPE=InnoDB statement, which should be ENGINGE=InnoDB. Even with the --compatible option it still keeps the STATS_PERSISTENT statement.
Is there a way to port a mysql 5.7 database to mysql 5.5?
UPDATE
To be clear on my question, I am looking for relialble, i.e. no-hack way, to port the database. I already tried to replace TYPE with ENGINE, remove STATS_PERSISTENT etc. Something else always came up. I am not willing to jump through those hoops everytime I port the database. I am looking for a reliable way via mysqldump or a similiar tool to do the job.
If this is not possible then I will have to switch to an alternative DB.

I am trying to drop MySQL database but it's showing an error in console

In console I am trying to drop database using command
drop database database_name;
But it's throwing the below error.
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 'database check' at line 1
I also tried to use another command:
mysqladmin -u root -p drop check;
It is throwing an error below
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 'mysqladmin -u root -p drop check' at line 1
How to fix it?
CHECK is a reserved word in MySQL, you should use back-tick character to escape it:
DROP DATABASE `check`;
In future, try to avoid using reserved words as names of tables/databases to prevent such things from happening.

Getting SQL syntax error while importing table into database using Mysql

I am getting the following error while trying to import the table into database using MySQL on my Ubuntu machine.
Error:
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 'mysql -u root -p spesh db_hit_type < /var/www/html/spesh.com/public_html/portal/' at line 1
I was using the following command to import the table data.
mysql -u root -p spesh db_hit_type < /var/www/html/spesh.com/public_html/portal/js/db_hit_type.sql;
I think that you try to run this command in MySQL command promt or in some client program. You need to run mysql program from server console, not from mysql console.

mysql console > mysqlbinlog You have an error in your SQL syntax

I have WAMP installed that has been binary logging all changes in my database. I found the logs, the mysql console also shows them when I perform a SHOW BINARY LOGS. But when I try to read them by executing:
mysqlbinlog mysql-bin.000197
it gives me that error:
ERROR 1016(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 'mysqlbinlog mysql-bin.000197' at line 1
MySQL version is 5.5.20
have you used shell command ?
shell> mysqlbinlog mysql-bin.000197