System: Centos
Vesion:
Server version: 5.5.56-log Source distribution
What I did:
Have set the secure_file_priv in my /etc/my.cnf
mysql> SHOW VARIABLES LIKE "secure_file_priv";
+------------------+---------------+
| Variable_name | Value |
+------------------+---------------+
| secure_file_priv | /target_file |
+------------------+---------------+
Have restarted myssql service by service mysql restart, and inaddition I have restart the server/machine too
and I set chmod 777 /target_file
But I still get
>> select * from mytable into outfile '/target_file/config';
>> ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
Did I miss something?
Related
Hello i got an error when im about to insert datas to a column a tutorial in google said to use
SET SQL_mode= 'ALLOW_INVALID DATES'
Now I got error 1265 Data truncated for column 'BDAY' And the BDAY column now shows 0000-00-00
How do I revert it back to normal or do I just reinstall mysql?
Thanks so much
If you have changed the sql_mode on your configuration files, you can run below command on Linux to find the changes:
sudo grep -ir "ALLOW_INVALID DATES" /etc/
sudo grep -ir "ALLOW_INVALID DATES" /etc/mysql/
Default configuration files on Linux are stored on the etc folder.
On your configuration file set sql_mode to save it permanently:
[mysqld]
sql-mode="ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
On the MySQL command line you can set it for the session and global.
First check using:
mysql> show variables like '%sql_mode%';
+---------------+-----------------------------------------------------------------------------------------------------------------------+
| Variable_name | Value |
+---------------+-----------------------------------------------------------------------------------------------------------------------+
| sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
+---------------+-----------------------------------------------------------------------------------------------------------------------+
mysql> show global variables like '%sql_mode%';
+---------------+-----------------------------------------------------------------------------------------------------------------------+
| Variable_name | Value |
+---------------+-----------------------------------------------------------------------------------------------------------------------+
| sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
+---------------+-----------------------------------------------------------------------------------------------------------------------+
Then you change it using:
SET GLOBAL sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
SET SESSION sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
I have a mysql database dump with 25GB of size
i use mysql 8 to import this dump
[root#hotsing] mysql -V
mysql Ver 8.0.15 for Linux on x86_64 (MySQL Community Server - GPL)
I run this command mysql -u root -p mydatabase < MySQLDump.sql
During import, this error message is show and the operation is failed
ERROR 1231 (42000) at line 22715: Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER'
this is my sql mode
mysql> SELECT ##sql_mode;
+-----------------------------------------------------------------------------------------------------------------------+
| ##sql_mode |
+-----------------------------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
+-----------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
how i can resolve this , it is error from the dump or misconfiguration of mysql ? or the version of current mysql and the version of the database dump ?
thank You
I had set --secure-file-priv as following:
mysql> show variables like '%secure%';
+--------------------------+----------+
| Variable_name | Value |
+--------------------------+----------+
| require_secure_transport | OFF |
| secure_auth | ON |
| secure_file_priv | E:\test\ |
+--------------------------+----------+
but I got an error like this:
D:\Tool\mysql-5.7.17-win32\bin>mysqlimport -u root -p my_test tb < e:test/new/outfile.sql
Enter password:
mysqlimport: Error: 1290, The MySQL server is running with the --secure-file-priv option so it cannot execute this statement, when using table: tb
Another error:
D:\Tool\mysql-5.7.17-win32\bin>mysqlimport -u root -p my_test tb < e:test\new\outfile.sql
Enter password:
mysqlimport: Error: 1290, The MySQL server is running with the --secure-file-priv option so it cannot execute this statement, when using table: tb
what should I do to tackle this?
The fact is that in my.ini you did not specify the correct directory
Secure File Priv.
secure-file-priv="F:/directory"
I am using mysql Server version: 5.5.37 and in current mysql whenever i will restart mysql service that time i saw below results
mysql> select ##GLOBAL.sql_mode;
+--------------------------------------------+
| ##GLOBAL.sql_mode |
+--------------------------------------------+
| STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION |
+--------------------------------------------+
1 row in set (0.00 sec)
mysql> select ##session.sql_mode;
+--------------------------------------------+
| ##session.sql_mode |
+--------------------------------------------+
| STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION |
+--------------------------------------------+
1 row in set (0.00 sec)
But i want to set mysql mode for both(session as well as global) whenever service is restart.i have also tried to put below line in /etc/my.cnf file
but its not working fine
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION
so is it possible to set from any core file or else where ?
please shine on this topic
i need help to set up session and global both sql_mode to 'NO_ENGINE_SUBSTITUTION'
This is how I set SQL mode in my /etc/my.conf file:
[mysqld]
sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
Make sure your MySQL daemon has permissions to read this file. Also, check if there are any other my.conf files that may override your value. MySQL searches and reads config files in multiple locations. Read more here http://dev.mysql.com/doc/refman/5.7/en/option-files.html
I am in a MySQL terminal session but I don't know what server I am connected to, or what database I am connected to.
Is there a MySQL command that will tell me the host, port, and username and database I am using now?
There are MYSQL functions you can use. Like this one that resolves the user:
SELECT USER();
This will return something like root#localhost so you get the host and the user.
To get the current database run this statement:
SELECT DATABASE();
Other useful functions can be found here: http://dev.mysql.com/doc/refman/5.0/en/information-functions.html
You can use the status command in MySQL client.
mysql> status;
--------------
mysql Ver 14.14 Distrib 5.5.8, for Win32 (x86)
Connection id: 1
Current database: test
Current user: ODBC#localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.5.8 MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: gbk
Conn. characterset: gbk
TCP port: 3306
Uptime: 7 min 16 sec
Threads: 1 Questions: 21 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.48
--------------
mysql>
If you want to know the port number of your local host on which Mysql is running you can use this query on MySQL Command line client --
SHOW VARIABLES WHERE Variable_name = 'port';
mysql> SHOW VARIABLES WHERE Variable_name = 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 3306 |
+---------------+-------+
1 row in set (0.00 sec)
It will give you the port number on which MySQL is running.
If you want to know the hostname of your Mysql you can use this query on MySQL Command line client --
SHOW VARIABLES WHERE Variable_name = 'hostname';
mysql> SHOW VARIABLES WHERE Variable_name = 'hostname';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| hostname | Dell |
+-------------------+-------+
1 row in set (0.00 sec)
It will give you the hostname for mysql.
If you want to know the username of your Mysql you can use this query on MySQL Command line client --
select user();
mysql> select user();
+----------------+
| user() |
+----------------+
| root#localhost |
+----------------+
1 row in set (0.00 sec)
It will give you the username for mysql.