Docker MySQL server failed [duplicate] - mysql

I am trying to import time zones according to this document: http://dev.mysql.com/doc/refman/5.7/en/mysql-tzinfo-to-sql.html.
When I try hitting even first command through terminal i.e.
mysql_tzinfo_to_sql tz_dir
it says
There were fatal errors during processing of zoneinfo directory 'tz_dir'
When I run:
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
then it returns
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
Operating System: Ubuntu
Server: XAMPP (having mariadb)
So, I am not able to import timezone data into the zone tables of mysql database.

I also had this issue this morning while trying to populate the timezone tables on our production server (using CentOS).
I worked around this problem by exporting the table creation script from my development computer (populating the tables on Windows simply requires to download the tables and copy them in the proper directory).
I tweaked the creation script a little bit and it is now working for me:
I cannot post it in my answers since the script is too long.
https://drive.google.com/file/d/0B7iwL5F-hwr_YkItRXk2Z1VZdlE/view?usp=sharing
Here's a version with the comment (but it doesn't seems to work, so use the version without comments).
https://drive.google.com/file/d/0B7iwL5F-hwr_dWdjTDREcXNHQmM/view?usp=sharing
The script should take no more than a few second to run. You'll probably need to use the root user to be able to run it.
You can use this query in order to validate the installation:
SELECT CONVERT_TZ(CURRENT_DATE(),'UTC','America/Montreal');
If it returns NULL instead of a datetime, it means the script failed.
Good success

The
There were fatal errors during processing of zoneinfo directory 'tz_dir'
error message means that the directory cannot be read (not enough access rights or not even exists).
Knowing that the mysql_tzinfo_to_sql program is just a tool that converts a bunch of timezone files into an SQL script that you can use to install the time zones for mysql, your task is the following:
obtain the timezone files from somewhere
execute mysql_tzinfo_to_sql to create an SQL script from those files
execute that SQL script in your mysql database.
These steps can be performed on different computers if you transfer the files between them. For example, I installed the timezones on a machine where the mysql installation was not complete, that is, mysql_tzinfo_to_sql was not available and I wasn't able to install it either.
In such a case you can combine the following steps:
if mysql_tzinfo_to_sql is not available on the computer where your mysql database resides then find a computer where mysql_tzinfo_to_sql is already installed
make the zoneinfo folder available on that computer. It is just a bunch of files in different folders so you can transport them in a gzip file from one computer to the other. In a normal mysql installation this folder should exist but maybe your installation is not complete, su just get it from anywhere.
execute the mysql_tzinfo_to_sql command to create an SQL script like this:
mysql_tzinfo_to_sql path-to-your-zoneinfo-folder >install_mysql_zoneinfo.sql
move the created SQL script to the computer where your mysql database resides *
execute the script like this:
mysql --user=root --password=abc123 mysql <install_mysql_zoneinfo.sql
Adjust the username and password if needed and your script will be executed. This will fill up the timezone-related tables with the appropriate values and you will be able to use them:
SELECT convert_tz(NOW(),'UTC','Australia/Melbourne');
if you can reach the mysql database from the computer where the SQL script was generated then it's enough to add the -h <hostname> command line argument to the subsequent script-executing program and you will not have to copy the SQL script to the target machine.

Related

Can't Connect MYSQL server to VScode & General SQL installation issues

How do I install MySQL Workbench properly? Can't connect to the SQLTools extension in VSCode.I'm new to the database scene, and can't seem to grasp how to create a successful SQL server that I can use to manipulate data. But nothing I'm doing seems to work.
Should I use Gitbash to access the terminal? I tried using my password to make a new query but it wouldn't work on the workbench. I don't know how to start the SQL server in addition to not knowing how to properly change the profile for the Workbench from a previous account. A new developer, such as myself, would appreciate any insight!
So that's really simple just install the mysql community server installer using this link https://dev.mysql.com/downloads/mysql/
Make sure to select the server only in the setup during installation if you are going to be using VS code as the client to manipulate sql queries
Then once that is done copy the bin path location from the mysql file directory (which is usually in the program files on your \C: drive on your computer) to the environment variables on your computer so that you can access mysql from the command line
Once that is done you can initialise a database from the normal command line but first type mysql -u root -p to start mysql in the command line
Then download the sql tools extension on vs code and create the database that wish

Installing (minimal) MySQL Workbench to simply join data from two .csv files (connections???)

I previously used MySQL Workbench to do this, in an environment that was already set up.
How do I set up a minimal working environment to just create and join tables on my own computer? (Connections???)
More details:
I downloaded and installed MySQL Workbench, and I can't even run SELECT sysdate();. There's a red x next to it. If I try "CREATE DATABASE MY_DATABASE; there's a green check, but the execute button is grey.
Doing some reading I apparently need "connections." Reading about that, I apparently need to also install MySQL Database Server. Who knows what else.
So, again, the question is how do I set up a minimally working environment to just create tables from .csv files, join them with MySQL commands, and export the results to another .csv file? (I know the syntax of the command to import a .csv file, and how to join tables.)
Thanks.
Install MySQL WorkBench AND MySQL Server.
From the command line, in the directory where MySQL server is installed, execute "mysqld --initialize" (One time only.)
execute "mysqld" from the command line, after the initialization given in step 1, and after any reboots. (It runs in the background, and doesn't exit when you exit MySQL WorkBench. (It can optionally be installed as an automatically running Windows service during installation.)
Execute Database -> Connect to Database upon starting MySQL WorkBench (each time you start the application). The default local host connection works fine.
After doing File -> New Model and setting up table(s), do Database -> Forward Engineer. This will place your new database in the Schemas section on the home/main window.
Double click on the Schema you created (default name is mydb) and it changes to bold font. Now scripts you run from that main window will run against the database you created.

Expand mysql memory

I am trying to import data base, that is more than 128 MB limit, to mysql on XAMMP machine. How can I expand the mysql memory on XAMMP?
Assuming you're using PHPMyAdmin, you can't - that's a hard limit.
To do it via PHPMyAdmin, you need to split your import files up and run them separately
Alternatively, use a different MySQL client, like the mysql command line client that comes as part of XAMPP, and allows you to run scripts directly.
The mysql command allows you to connect to the database using the client, and then run the script from there, like this:
C:\xampp\mysql\bin>mysql.exe -u root
mysql> source C:/mysqlscripts/import.sql;
Note the forward slashes in the file path
Or, you can run it on the windows commandline with the file as a parameter, as described in the documentation.

MySQL command line client for Windows

Is there any nice command line MySQL client for windows? I mean a single exe that allows connecting and running a sample query. I've googled and only could find big graphical environments like toad or mysql workbench. I need only a simple command line tool, where can I download sth like this?
EDIT: I don't want to install the whole MySQL package on my PC. I know it's inside the mysql package but how do I download only this cmd line client. Because i don't need anything else.
When you go to the MySQL download page, choose the platform "Microsoft Windows". Then download the "Windows (x86, xx-bit), ZIP Archive" (be sure to select the one with size over 140M.
The binaries will be in the "bin" folder.
I understand that this is not just the client binaries, but at least you don't have to install and setup the entire server.
mysql.exe can do just that....
To connect,
mysql -u root -p (press enter)
It should prompt you to enter root password (u = username, p = password)
Then you can use SQL database commands to do pretty much anything....
You can choose only install the client during server install. The website only offers to let you download the full installer (grab whatever version you want from http://www.mysql.com/downloads/mysql/).
In the install wizard, when prompted for installation type (typical, minimal, custom), choose 'Custom'. On the next screen, select to NOT install the server, and proceed with the rest of the install as normal.
When you're done, you should see just the relevant client programs (mysql, mysqldump, etc) in C:\Program Files\MySQL..\bin
Its pretty simple. I saved the mysql community server in my D:\ drive. Hence this is how i did it.
Goto D:\mysql-5.7.18-winx64\bin and in the address bar type cmd and press enter, so command prompt will open. Now if you're using it for the first time type as mysql -u root -ppress enter. Then it will ask for password, again press enter. Thats it you are connected to the mysql server.
Before this make sure wamp or xampp any of the local server is running because i couldn't able to connect to mysql wihthout xampp running.
Happy Coding.
You can also download MySql workbench (31Mo) which includes mysql.exe and mysqldump.exe.
I successfully tested this when i had to run Perl scripts using DBD:MySql module to run SQL statements against a distant MySql db.
You can access mySQL in command line just by typing:
C:\www\mysql\bin> mysql -u root -p
After which you can type sql commands normally such as:
mysql> SHOW DATABASES;
Here, I am assuming you mySQL installation directory is C:\www\mysql.
I have similar requirement where I need a MySQL client but not server (running in a virtual machine and don't want any additional overhead) and for me the easiest thing was to install MySQL community server taking typical installation options but NOT configure the server, so it never starts, never runs. Added C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin to system path environment variable and I'm able to use the MySQL command line client mssql.exe and mysqladmin.exe programs.
If you are looking for tools like the the mysql and mysqldump command line client for Windows for versions around mysql Ver 14.14 Distrib 5.6.13, for Win32 (x86) it seems to be in HOMEDRIVE:\Program Files (x86)\MySQL\MySQL Workbench version
This directory is also not placed in the path by default so you will need to add it to your PATH environment variable before you can easily run it from the command prompt.
Also, there is a mysql utilities console but it does not work for my needs. Below is a list of the capabilities on the mysql utilities console in case it works for you:
Utility Description
---------------- ---------------------------------------------------------
mysqlauditadmin audit log maintenance utility
mysqlauditgrep audit log search utility
mysqldbcompare compare databases for consistency
mysqldbcopy copy databases from one server to another
mysqldbexport export metadata and data from databases
mysqldbimport import metadata and data from files
mysqldiff compare object definitions among objects where the
difference is how db1.obj1 differs from db2.obj2
mysqldiskusage show disk usage for databases
mysqlfailover automatic replication health monitoring and failover
mysqlfrm show CREATE TABLE from .frm files
mysqlindexcheck check for duplicate or redundant indexes
mysqlmetagrep search metadata
mysqlprocgrep search process information
mysqlreplicate establish replication with a master
mysqlrpladmin administration utility for MySQL replication
mysqlrplcheck check replication
mysqlrplshow show slaves attached to a master
mysqlserverclone start another instance of a running server
mysqlserverinfo show server information
mysqluserclone clone a MySQL user account to one or more new users
mysql.exe is included in mysql package. You don't have to install anything additionally.
download the mysql-5.0.23-win32.zip (this is the smallest possible one) from archived versions in mysql.com website
cut and paste the installation in c drive as mysql folder
then install then follow instructions as per this page:
https://cyleft.wordpress.com/2008/07/20/fixing-mysql-service-could-not-start-1067-errors/
For Windows users:
1.Install the full version of MYSQL
2.On the Windows 10 start button click on search and type in MySQL
3. Select the MYSQL Command Line Client 5.5 (I am using version 5.5)
4. go ahead and run your sql queries/
5. to exit type \q or quit

MySQL mysql_tzinfo_to_sql program

I am using MySQL 5.0.51b on microsoft windows xp. I am trying to load data from zoneinfo files(generated by library downloaded from here) to database tables as described here.
Now i am not able to find where would i get this "mysql_tzinfo_to_sql" program for windows. I tried executing it on mysql command line client but no success.
On linux you can directly execute this command on the shell.
Any help is appreciated.
You don't need to run mysql_tzinfo_to_sql on Windows.
For Windows just do this:
Download the files. Links here
Move them to your MySQL directory.
Example: C:\ProgramData\MySQL\MySQL Server 5.5\data\mysql
Restart your server.
Now, if you want, you can change your timezone like this: SET time_zone = 'America/Costa_Rica';
Check it with SELECT NOW();
More information here: MySQL
And take a look at this: Answer
The command "mysql_tzinfo_to_sql" doesn't work on Windows.
You have to download the timezone packages wich contains SQL statements and populate the timezone tables using the "source" command, like this:
mysql> use mysql ;
mysql> source /path/to/file/timezone_posix.sql ;
Check the following links for reference:
Blog: https://discourse.looker.com/t/cannot-connect-time-zone-tables-dont-appear-to-be-loaded-in-mysql/208/6
Scripts sql: http://downloads.mysql.com/general/timezone_2016a_posix_sql.zip , http://downloads.mysql.com/general/timezone_2016a_leaps_sql.zip
None of the 'populate file' methods worked for me with mysql 8.
A lot of answer contains this link: http://dev.mysql.com/downloads/timezones.html
There's downloadable zip files that contain sql files. Putting it to any directory didn't help.
One thing helped me: I issued a "use mysql;" and executed the content of the downloadable sql file as a script.
based on Francisco Corrales Morales answer.
For MySQL 5.7+ on Windows 10 machine, my procedure is
download latest POSIX Standard time zone script under 5.7+ section from https://dev.mysql.com/downloads/timezones.html
Extract the file then there would be a single SQL file named timezone_posix.sql
run the sql script, in my case, use command line below
bin\mysql.exe --host=localhost --port=3306 --user=USERNAME -p mysql < c:\...\Downloads\timezone_2020d_posix_sql\timezone_posix.sql
Note make sure you run the time zone script under mysql database/schema.
For Windows, MySQL supplies an already loaded database for you to download and stick in your data directory: http://dev.mysql.com/downloads/timezones.html
Copied from the user comments on the MySQl docs:
Posted by Jyotsna Channagiri on
November 20 2008 6:28pm
Hi,
I thought this information will helps
somebody who are looking for changing
mysql timezone.
The steps are:
Download the timezone table structure and data from
http://dev.mysql.com/downloads/timezones.html
Copy and paste the data in your Mysql/data/mysql folder
Restart your mysql server.
mysql> SET GLOBAL time_zone = 'America/Toronto';
mysql> SET SESSION time_zone = 'America/Toronto';
Check SELECT # #global.time_zone , # #session.time_zone ; It should give
you the time zone you set just before.
Comment:
Yes, but the tables provided by MySQL are outdated (generated by 2006p version of D olson's timezone library). I need the latest timezones data, hence i downloaded the latest library and generated the binaries. Now i need a way to load these tables in mysql.But i don't know how to do it on windows.
Ah, I see. Then you're going to need to do one of two things.
1) get the tool that does this and compile it (or whatever) on Windows. If you're lucky, it's a perl script.
2) fill the database on linux, then copy it to Windows. [This guy][http://it-idiot.einsamsoldat.net/2008/01/moving-mysql-database-from-windows-to-linux-redhat/comment-page-1/2] says it can be done, at least for MyIsam.
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -uadmin -ppassword mysql
I am using XAMPP and PHP 7.4.27 on Windows 10 and had some difficulties getting other solutions to work.
Here are the steps I took to get it working was what worked for me.
Download the latest MySQL Community Downloads POSIX Standard or the Non POSIX with leap seconds(if you need the leap seconds included) time zone script under the section that states:
Each file contains SQL statements to fill the tables
Extract the file, which should be a single SQL file named timezone_posix.sql.
Open the extracted SQL file in the code editor of your choice and copy its content.
Open your DB administration tool of choice, select the "mysql" table and under the "SQL" tab paste the contents of the extracted file.
Note: #4 Instructs on the basis of PHPMyAdmin, other administration tools might have a different process.
Click "Go" and follow any prompts after that.
All needed time_zone tables should be populated with timezone data