MySQL cannot enable LOAD DATA LOCAL INFILE on server - mysql

First I am a novice MySQL user so I would please ask that in answers to keep it very by the numbers if steps are skipped I will probably get lost.
I have tried vigorously to research solutions before asking this, so far I have spent about 3 hours on this. I will explain what steps I have taken to the best of my abilities.
Goal: Allow the use of the LOAD DATA LOCAL INFILE
Challenge: Currently the command is not allowed on the server. All attempts to locate and open some method to modify server options has proved fruitless. On the client side I was able to enable it.
Things I have found
First under the official Tutorial I found
Section 6.1.6, “Security Issues with LOAD DATA LOCAL”
https://dev.mysql.com/doc/refman/8.0/en/load-data-local.html
Unfortunately the explanation is worthless because it skips a huge amount of how to, they state to enable it on the server to take the following action
On the server side:
The local_infile system variable controls server-side LOCAL capability. Depending on the local_infile setting, the server refuses or permits local data loading by clients that have LOCAL enabled on the client side. By default, local_infile is disabled.
To explicitly cause the server to refuse or permit LOAD DATA LOCAL statements (regardless of how client programs and libraries are configured at build time or runtime), start mysqld with local_infile disabled or enabled, respectively. local_infile can also be set at runtime.
So the following actions are not in any way explained
1) How to start mysqld with local_infile disabled or enabled
2) How the local_infile can also be set at runtime
So then I looked at this
5.1.1 Configuring the Server
https://dev.mysql.com/doc/refman/8.0/en/server-configuration.html
Again many skipped steps they show this
shell> mysqld --verbose --help
How do you get to shell? I tried on cmd to input that but I got errors
Also to note a my.ini was not created, and under the MySQL Workbench when looking under Options File it says
"Location of My SQL configuration file (ie: my.cnf) not specified"
It appears I do not have one and I have no idea how to create one
Finally I am running Windows 10 and MySQL version 8.0
As a side note I tried shutting down the server and got and Access denied
Also I tried just doing
mysql> LOAD DATA INFILE 'C:/Users/User/Desktop/pet.txt' INTO TABLE pet;
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
Any help would be much appreciated
Thank you

Whew 4 hours later and I finally figured it out!
So here are the steps
Open Window Services
Go to MySQL80 and double click
Go to Service Status and click Stop
Under Start parameters insert --local-infile=1
Open MySQL 8.0 Command Line Client
After you login excute on the command line SET GLOBAL local_infile ='ON;
These steps allowed me to use LOAD DATA LOCAL INFILE

Related

How to make a replication in MariaDB with windows 10? Error 1067 with the service

I have been looking for how to create a database replication with MariaDB but the steps I find on the official page of how to do it https://mariadb.com/kb/en/setting-up-replication/ give me an error in this He passed:
Example that enables replication for MariaDB
Add the following to your my.cnf file and restart the database.
[mariadb]
log container
server_id = 1
log-basename = master1
binlog-format = mixed
When I change the file, I get a 1067 error when restarting the MariaDB service. All the examples I find, are solutions for Linux, also try changing the environment variables. Is there a solution to this error? Or is there another way to create a replication?
I already resolved it!. The error was because I followed the tutorial deleting what the default my.ini file contains and I replaced it with what the tutorial told me and what you have to do is add the new configuration below to the file and that's it.
Then the same is done with the slave, remembering to change the server number.

Google Cloud SQL instance always in Maintenance status & Binary logs issue

I've had some of Google Cloud SQL MySQL 2nd Gen 5.7 instances with failover replications. Recently I noticed that the one of the instance overloaded with the storage overloaded with binlogs and old binlogs not deleted for some reason.
I tried restart this instance but it wont start since 17 March.
Normal process with binlogs on other server:
Problem server. Binlogs not clearing and server wont start and always under maintenance in the gcloud console.
Also I created one other server with same configuration and not binlogs never clearing. I have already 5326 binlogs here when on normal server I have 1273 binlogs and they are clearing each day.
What I tried with the problem server:
1 - delete it from the Google Cloud Platform frontend. Response: The instance id is currently unavailable.
2 - restart it with the gcloud command. Response: ERROR: (gcloud.sql.instances.restart) HTTPError 409: The instance or operation is not in an appropriate state to handle the request. Same response on any other command which I sent with the gcloud.
Also I tried to solve problem with binlogs to configure with expire_logs_days option, but it seems this option not support by google cloud sql instance.
After 3 days of digging I found a solution. Binlogs must cleared automatically when 7 days past. In 8 day it must clear binlogs. It still not deleted for me and still storage still climbing, but I trust it must clear shortly (today I guess)
As I told - SQL instance always in maintenance and can't be deleted from the gcloud console command or frontend. But this is interesting because I still can connect to the instance with the mysql command like mysql -u root -p -h 123.123.123.123. So, I just connected to the instance, deleted database which unused (or we can just use mysqldump to save current live database) and then I just deleted it. In the mysql logs (I'm using Stackdriver for this) I got a lot of messages like this: 2018-03-25T09:28:06.033206Z 25 [ERROR] Disk is full writing '/mysql/binlog/mysql-bin.034311' (Errcode: -255699248 - No space left on device). Waiting for someone to free space.... Let's me be this "someone".
When I deleted database it restarted and then it up. Viola. And now we have live instance. Now we can delete it/restore database on it/change storage for it.

percona toolkit Replication filters error

I put the percona toolkit onto my DB hosts so I could try and deal with a problem with mysql going silently out of sync. That is replication seems fine on all nodes. Slave IO running / Slave SQL running and 0 seconds behind master.
I have 4 dbs setup in master/master on the first two, and two slaves, I'm using MariaDB-server-10.0.21 for the MySQL database on each node.
Yet the content of the wiki I run on them seems to go out of sync even with those positive indicators. For instance, you'll create a page, save it, get the thumbs up from the wiki. Then reload the page and the content will be gone! Then you point the wiki config to look at each db one at a time, reload the page. Until you find the db that saved the changes you made.
Then dump that db, stop the slaves on each host one at time and then import that version of the database. It's a real pain!
So I installed the percona toolkit after reading an article on how to solve this problem.
And when I run the pt-table-checksum command I get this error, saying Replication filters are set on these hosts:
[root#db1:~] #pt-table-checksum --replicate=test.checksum --databases=sean --ignore-tables=semaphore localhost
10-17T00:31:11 Replication filters are set on these hosts:
db3
binlog_do_db = jfwiki,jokefire,bacula,mysql
db2
binlog_do_db = jfwiki,jokefire,bacula,mysql
db4
binlog_do_db = jfwiki,jokefire,bacula,mysql
Please read the --check-replication-filters documentation to learn how to solve this problem. at /bin/pt-table-checksum line 9644.
But that EC2 host it claims that it's having trouble contacting equates to my 4th database host. I found out by ssh'ing in as my user to that DNS address. And I have no trouble at all logging into that host on the command line using mysql:
Can someone please explain what does this error mean, and how can I fix the issue? Is there any general advice you can give for mysql replication falling silently out of sync?
Thanks
Some of the pt tools need to create their own database and have it replicated. Your binlog_do_db prevents the extra db from being replicated, hence preventing that tool from working.
While you have the binlog_do removed, see what db it being built. Then add it.

MySql General Query Log

Does restarting the MySQL service on Linux, disables the already enabled general query logging?
There was a log file getting generated inside the data folder, and it was growing exponentially. The db has 100 requests per minute.
Initially i guessed, some transaction had broken in between, that made the logs to swell.
So i restarted the service, which stopped adding to that log file.
I checked the global variables and got to know the path was assigned for general_log_file. But now it was showing 'OFF'.
Hence my query
It's a common issue that people will set configuration of MySQL through dynamic (global) variables and forget to set the variables in the options file (my.conf). In that case, when the server is restarted, MySQL will revert to default settings.
The default setting for general_log is OFF. To immediately enable the general query log, set the global variable to ON. Then set the value for general-log in your my.conf file to ensure that the setting is applied whenever you restart MySQL server.
No, Restarting the server doesn't make the binary logs to OFF...
It may be the case that you changed the configuration file before and now restart takes that file...
MySQL will start with whatever options are in the file configuration. If you switched any of the global server variables before, they will be reverted to what is set in the file.

MySQL binary log after restore

I've got an issue with a legacy system I've inherited. Every night a dump from live is run (to script) and restored to QA from said script e.g.:
mysql [params] < path/to/backup.sql
This causes the creation of lots data in the bin logs (DB is a few gigabytes). The bin logs don't seem to get flushed automatically - I can clear them down by running RESET MASTER; from the mysql command line but was wondering if there was any way to automate this? It's running on mysql 4.0.21 under Windows.
EDIT:
It's not running as a master to any slave dbs
flush logs
or update & restart mysql server by comment out log-bin = xxx,
but this will disabled the replication
The following will disable sql statements being logged to binary.
mysql> set sql_log_bin=0
mysql> source path/to/backup.sql
This applies to current thread only and is much faster.