I am trying to print my result tables into a csv file or a text file and I use into outfile in mysql but I get this error:
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
I have tried to set this secure-file-priv to "" but i cant really find my.cnf file in my mac. The locate result of my.cnf is like:
/usr/local/Cellar/mysql/5.7.16/mysql-test/include/default_my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/federated/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndb/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndb_big/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndb_binlog/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndb_ddl/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndb_memcache/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndb_rpl/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndb_team/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndbcluster/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/rpl/extension/bhs/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/rpl/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/rpl_ndb/my.cnf
I dont think any of them is the one that I need to add [mysqld] secure-file-priv="" to.
Also I tried to set it in mysql but it's read only and I cannot change it. I even tried to to stop and restart my mysql after adding a my.cnf file manually in /etc/ but then I was not able to start the server again and use mysql.
I am using mysql Ver 14.14 Distrib 5.7.20, for osx10.12 (x86_64)
Followed below steps to changes -secure-file-priv
Look for "my.cnf" file which is located at /usr/local/etc
add secure-file-priv = "" into my.cnf
restart mysql using /usr/local/opt/mysql/support-files/mysql.server restart
After restart I am able to use OUTFILE command on mysql.
I reviewed setting on MySQL Workbench.
In "Options Files", it was set to the correct value. But in "Administration - Status and System Variables", it keeped as default value NULL. Although I restarted the server.
After some researches, I found it was cased by the wrong file permission. What I had at the beginning is:
-rw------- 1 root wheel 31 Mar 24 13:31 my.cnf
And I use command chmod 0755 changed the permission to:
-rwxr-xr-x 1 root wheel 31 Mar 24 13:31 my.cnf
Then restart the server, I can see both "Options Files" and "Administration - Status and System Variables" have the same value and status.
This is what it looks like on my server. I can't put a screen shot into the comments.
Related
I'm installing new software on a new Ubuntu 16.0.4 machine and installed MySQL with apt-get. The version I get is 5.7.22 but can't get it to accept
my settings of the configuration variable lower_case_table_names.
I'm adding lines like:
[mysql]
lower_case_table_names = 1
When I edit any of the *.cnf files in /etc/mysql to have this setting or if I add it to ~/.my.cnf I get
mysql: [ERROR] unknown variable 'lower_case_table_names=1'
if I try to start mysql. Similarly I can't use it on the mysql command line like the doc says I can.
/usr/bin/mysql --lower_case_table_names=1 -u root -p
However:
If I go into the SQL command interpreter and type
mysql> select ##lower_case_table_names;
I get back a result showing the variable is set to 0. However it cannot be changed with a SET statement...
So whats the deal with why I can't set this variable ?
~/.my.cnf file:
[mysqld]
lower_case_table_names = 1
[mysql]
lower_case_table_names = 1
Why is mysql not liking this variable name when clearly it still has a setting for it?
The problem is that this variable does not apply to mysql. It only applies
to mysqld. Stop mysqld, change the my.cnf to have a setting for [mysqld], and then start mysqld. This will set the lower_case_table_names value for the mysql server.
If you run /usr/bin/mysql (a command line mysql shell) it will not want a setting for this var in the config file. The shell will behave as the mysql server behaves.
I am importing dump file in mariadb on windows . It show me "Mysql server has gone away" error . I knew the solution that add
max_allowed_packet=500M
in my.cnf but issue is that is have seen five init files in that directory
C:\Program Files\MariaDB 5.5
my-huge.ini
my-innodb-heavy-4G.ini
my-large.ini
my-medium.ini
my-small.ini
so in which file i change "max_allowed_packet=500M" .Please suggest to me how i change the configuration of mariadb on windows for this issue.
I have face same problem because configuration file did not work for me,so you have to pass max_allowed_packet value directly in a query.
mysql -u username -p --max_allowed_packet=1073741824 < dump.sql
None of these .ini files are used by your server, with default installation. Those are examples.
my.ini in the data directory is used, which in default installation is in
C:\Program Files\MariaDB 5.5\data
I needed to set up the system variable "show_compatibility_56" to ON in MySQL. So, I run the command set global show_compatibility_56 = on;, and it worked However, I noticed that whenever I stop and then start the MySQL server, this variable goes back to OFF. Any hints on how to keep it always ON even if I restart the server?
I'm using a Laravel Homestead (Vagrant) box (MySql Ver 14.14 Distrib 5.7.17).
I needed to SSH into Homestead and then run:
echo "[mysqld]
show_compatibility_56 = ON
performance_schema" | sudo tee -a /etc/mysql/conf.d/mysql.cnf >/dev/null
sudo service mysql restart
(Thanks to Mark Reed for showing how to skip opening vim.)
Older version:
sudo vim /etc/mysql/conf.d/mysql.cnf
Then I added this section:
[mysqld]
show_compatibility_56 = ON
performance_schema
I was surprised that other answers here and elsewhere on the web didn't specify that it needed to be under [mysqld] instead of [mysql] and also that you must restart the MySql service:
sudo service mysql restart
you need to save this variable setting in your configuration file my.cnf for linux and my.ini for windows.
To make it permanent, you need to add this variable in configuration file of MySQL like we did for all other variables as:
show_compatibility_56 = ON
For Linux based system: File name is my.cnf and default location is /etc/my.cnf
For Windows based system: File name is my.ini and default location is your windows mysql data directory that you can check via below command:
show variables like 'datadir';
If you've installed MySQL through Hombrew on a Mac, there isn't a my.cnf by default. I created one in /etc/my.cnf, added the text from #Ryan's answer:
[mysqld]
show_compatibility_56 = ON
performance_schema
... and then restarted MySQL, with (I'm using the older 5.7 version):
$ brew services restart mysql#5.7
This worked for me.
As Zafar has already pointed you can set the variable in the configuration file to save the value.
Also note that this is now deprecated. The manual says:
Note:
show_compatibility_56 is deprecated because its only purpose is to
permit control over deprecated system and status variable information
sources that will be removed in a future MySQL release. When those
sources are removed, show_compatibility_56 will have no purpose and
will be removed as well.
I want to change the default port number of MySQL server presently it is 3306. I want to change it to 3360.
I have tried:
-- port=3360
But things are not working for me. Please provide query to change port not any configuration. I am using Windows 8 64 bit.
You need to edit your my.cnf file and make sure you have the port set as in the following line:
port = 3360
Then restart your MySQL service and you should be good to go. There is no query you can run to make this change because the port is not a dynamic variable (q.v. here for MySQL documentation showing a table of all system variables).
If you're on Windows, you may find the config file my.ini it in this directory
C:\ProgramData\MySQL\MySQL Server 5.7\
You open this file in a text editor and look for this section:
# The TCP/IP Port the MySQL Server will listen on
port=3306
Then you change the number of the port, save the file.
Find the service MYSQL57 under Task Manager > Services and restart it.
On newer (for example 8.0.0) the simplest solution is (good choice for a scripted start-up for example):
mysqld --port=23306
When server first starts the my.ini may not be created where everyone has stated. I was able to find mine in C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.6
This location has the defaults for every setting.
# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]
# pipe
# socket=0.0
port=4306 !!!!!!!!!!!!!!!!!!!Change this!!!!!!!!!!!!!!!!!
[mysql]
no-beep
default-character-set=utf8
Go to installed mysql path and find bin folder,open my.ini and search 3306 after that change 3306 to 3360
Actually, you can just run the service using /mysqld --PORT 1234, it would force mysql to run on the specified port without change the cnf/ini file.
I just cought a case that cnf didn't work. It was weired... so I just use the cmd line as the shortcut and it works!
try changing the connection port to 8012
open xampp as administrator
Mysql config => my.ini change the port from 3306 to 8012
close and run it again
I hope it will work.
If you are using windows and installed the database as a service, which is the default, you should find your configuration file by opening your services management console.
For instance: win + r and then type services.msc
Look for a service called MySQL or MariaDB.
On the general tab of the properties of this service you can find a path to your mysqld.exe file and the arguments to start the exe. The --defaults-file argument should point to your configuration file.
Edit your configuration file and restart the MySQL service.
In Windows 8.1 x64 bit os, Currently I am using MySQL version :
Server version: 5.7.11-log MySQL Community Server (GPL)
For changing your MySQL port number, Go to installation directory, my installation directory is :
C:\Program Files\MySQL\MySQL Server 5.7
open the my-default.ini Configuration Setting file in any text editor.
search the line in the configuration file.
# port = .....
replace it with :
port=<my_new_port_number>
like my self changed to :
port=15800
To apply the changes don't forget to immediate either restart the MySQL Server or your OS.
Hope this would help many one.
Change my.cnf file and add this line or change it port=3360
at my fedora 34
sudo vi /etc/my.cnf
add This line ==> port=3360
The best way to do this is take backup of required database and reconfigure the server.
Creating A Backup
The mysqldump command is used to create textfile “dumps” of databases managed by MySQL. These dumps are just files with all the SQL commands needed to recreate the database from scratch. The process is quick and easy.
If you want to back up a single database, you merely create the dump and send the output into a file, like so:
mysqldump database_name > database_name.sql
Multiple databases can be backed up at the same time:
mysqldump --databases database_one database_two > two_databases.sql
In the code above, database_one is the name of the first database to be backed up, and database_two is the name of the second.
It is also simple to back up all of the databases on a server:
mysqldump --all-databases > all_databases.sql
After taking the backup, remove mysql and reinstall it. After reinstalling with the desired port number.
Restoring a Backup
Since the dump files are just SQL commands, you can restore the database backup by telling mysql to run the commands in it and put the data into the proper database.
mysql database_name < database_name.sql
In the code above, database_name is the name of the database you want to restore, and database_name.sql is the name of the backup file to be restored..
If you are trying to restore a single database from dump of all the databases, you have to let mysql know like this:
mysql --one-database database_name < all_databases.sql
I have XAMPP installed on my computer, and am using MySQL through it on localhost for a personal project.
I am trying to set the ft_min_word_len variable for fulltext searches in boolean mode to 2 from the default of 4.
I've tried (after stopping MySQL from the XAMPP control panel):
Opening Shell from the XAMPP control panel, and typing at the prompt:
mysqld ft_min_word_len=2
This doesn't appear to have any effect on ft_min_word_len when I check its value afterwards with mysqld --help --verbose (I get an error when I try to use mysqladmin variables at the prompt).
Creating a my.cnf file in XAMPP\mysql\bin with this text:
# The MySQL server
[mysqld]
ft_min_word_len=2
This does appear to change the value of ft_min_word_len when I check its value with mysqld --help --verbose.However, when I start MySQL again from XAMPP's control panel, and then check the value of ft_min_word_len through PHPMyAdmin with SHOW VARIABLES LIKE 'ft_min_word_len', it is still 4, both before and after I rebuild the fulltext indexes.
I've tried each approach multiple times, in between stopping and starting MySQL. SHOW VARIABLES LIKE 'ft_min_word_len' did show a value of 2 once, but the next time I stopped and restarted MySQL, the value had returned to 4, and I have been unable to set it to 2 again.
Any pointers in the right direction would be appreciated.
mysql config file would usually be found on in windows your installation drive:\XAMPP\mysql\bin\my.ini or
Linux under etc\my.cnf.
if you does not get ft_min_word_len variable below the lines you simply add those line anywhere in the page
[mysqld]
ft_min_word_len = 3
then restart mysql server.
Keep you my.cnf file in <XAMPP>\mysql\bin folder and try again.