Is it possible to use period character in MySQL account names? I checked the documentation and tried to google but haven't found any convincing info.
Yes, it's possible, but you'll have to escape the username with quotes (").
E.g.:
Without quotes:
MariaDB [(none)]> create user name.surname;
ERROR 1064 (42000): 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 '.surname' at line 1
With quotes:
MariaDB [(none)]> create user "name.surname";
Query OK, 0 rows affected (0.00 sec)
yes only and only if you are using quotes e.g.
create user "myuser.lastname"
Related
I initially posted a question regarding why I was given a syntax error message here. I then created the user usermail with (I admit I misused IDENTIFIED BY but I don't think it matters in this case:
mysql> CREATE USER 'usermail'#'127.0.0.1' IDENTIFIED BY 'usermail';
Query OK, 0 rows affected (0.02 sec)
I then retried what I was initially trying to run.
mysql> GRANT SELECT ON servermail.* TO 'usermail'#'127.0.0.1' IDENTIFIED BY 'mailpassword';
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 'mailpassword'' at line 1
mysql> GRANT SELECT ON servermail.* TO 'usermail' IDENTIFIED BY 'mailpassword';
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 'mailpassword'' at line 1
mysql> GRANT SELECT ON servermail.* TO 'usermail'#'127.0.0.1' IDENTIFIED BY 'mailpassword';
I am still getting the exact same error. How was my question a duplicate? Or did I not follow the directions properly?
I've copied-pasted alter user "root"#"localhost" identified by "NEW PASSWORD"; into mysql>. The message is:
Query OK, 0 rows affected (0,00 sec)
But if I enter exactly the same command (tested several times!), the message is:
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 'indentified by "NEW PASSWORD"' at line 1
Why?
Please take a closer at the error the server returns; you're typing indentified instead of identified!
I'm trying to execute
ALTER USER 'root'#'localhost' IDENTIFIED BY 'my_new_password';
but getting
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 'my_new_password'' at line 1
What am i doing wrong?
The way you want to change the password is only valid since MySQL 5.7.6. You can use the SET PASSWORD statement for older versions instead:
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('my_new_password');
The ALTER USER statement is available since MySQL 5.7.6. Make sure you are using this version or a newer one to use your statement (thx #Dez).
I tried the following -
I created a variable at the command prompt as follows -
mysql> set #myId = 1;
Query OK, 0 rows affected (0.00 sec)
Then, to display it, I tried the following without success -
mysql> show myId;
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 'myId' at line 1
mysql> show #myId;
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 '#myId' at line 1
mysql> PRINT #myId;
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 'PRINT #myId' at line 1
mysql> PRINT myId;
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 'PRINT myId' at line 1
So how can I display the value of #myId?
Simply SELECT the variable like this:
SELECT #myId;
Here is the MySQL documentation on user-defined variables:
http://dev.mysql.com/doc/refman/5.5/en/user-variables.html
If you're looking for a variable that you set yourself like the OP did, then #MikeBrant's answer is correct:
SELECT #myId;
But if you want to see the MySQL system variables (which is what I came here looking for), then you need to run:
show variables like '%slow%';
or possibly:
show global variables like '%slow%';
SHOW GLOBAL STATUS LIKE '%com_stmt%';
may be used to determine any SHOW GLOBAL STATUS current values using wildcard.
Likewise,
SELECT ##thread_cache_size;
may be used to display any specific SHOW GLOBAL VARIABLES current value.
There are more than 300 GLOBAL STATUS values.
There are more than 400 GLOBAL VARIABLES with or without values. (Could be empty placeholders).
You CAN NOT create a GLOBAL VARIABLE in MySQL.
I have written the SQL file with on excecuting it is throwing the error as
mysql> #"C:\Documents and Settings\Hemant\Desktop\create_tables.sql";
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 '#"C:\
Documents and Settings\Hemant\Desktop\create_tables.sql"' at line 1
on line 1 code is
CREATE DATABASE IF NOT EXISTS test;
DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE test;
please let me know is i am missing something
Correct me if I'm wrong, but isn't there a table test by default when you setup PHPMyAdmin?
You have an extra semi column after test.
Try removing it and see if that fixes the issue.