Create database in SQL and get an error but everything right - mysql

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;

Related

MySql syntax error during user creation when there is no apparent error

I'm trying to install Moodle using Ubuntu using the following guide: Step-by-step Installation Guide for Ubuntu
I'm currently on step 6 where I have to create a mySQL user with the correct permissions and this is where I'm getting stuck.
The 1st command - create user 'user1'#'localhost' IDENTIFIED BY 'password1'; works fine
However the 2nd command -
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO user1#localhost
IDENTIFIED BY 'password1';
Returns the error message - 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 'IDENTIFIED BY 'password1'' at line 1
The installation manual mentions that this may be a problem so advises me to use - SELECT password('password1'); in order to get a hash value to overcome the problem.
However instead of giving me a hash value it comes up with the same error of - 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 '('password1')' at line 1
I am a beginner to all this so I'd appreciate any responses, thanks in advance!
You need apostrophes around the name and the host in your command, like:
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO 'user1'#'localhost'
IDENTIFIED BY 'password1';
EDIT
According to the comments, slightly changing the command fixed the syntax error:
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO 'user1'#'localhost';
First Create user ‘moodleuser’#’localhost’ identified by ‘yourpassword’;
Then grant select,insert,update,delete,create,create temporary tables,drop,index,alter on moodle.* to 'moodleuser'#'localhost';

Error when switching user in mysql client

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.

MySQL commands not working in phpMyAdmin

I am able to create databases and tables using the User Interface in phpMyAdmin , but when I do the same using MySQL commands , It does not work. I get this error :
SQL query:
DROP DATABASE 'alphacrm'
MySQL said: Documentation
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 ''alphacrm'' at line 1**
don't use quote
DROP DATABASE alphacrm;
my sql object don't need quotes eventually use backtics for reversed word and compite named eg:
`my obj`

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.

restoring mysql backup

I'm trying to restore database from backup. I've create new DB:
CREATE DATABASE `my_db` CHARACTER SET utf8
after that I launch big sql, afrter some time there written
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 ''oy7:
commandwy24:BroadcastCommandContentsy15:changeStructure:7y7:1080582i15ay7:1' at
line 1
Does anyone know what's up here? I've tried on two backups, and I don't think both are invalid.
Thank you in advance!