Migrate mysql to postgres using pgloader - mysql

I'm trying to migrate mysql to postgres using pgloader, since I'm using window so, I installed pgloader in
windows linux subsystem, and I have used following command to migrate the DB
pgloader mysql://root#localhost/f1db pgsql://postgres#localhost:5433/f1db
KABOOM!
FATAL error: Failed to connect to pgsql at "localhost" (port 5433) as user "postgres": Server requested md5-password authentication, but no password was given.
An unhandled error condition has been signalled:
Failed to connect to pgsql at "localhost" (port 5433) as user "postgres": Server requested md5-password authentication, but no password was given.
What I am doing here?
Failed to connect to pgsql at "localhost" (port 5433) as user "postgres": Server requested md5-password authentication, but no password was given.
Waiting for the monitor thread to complete.
Please tell that how to pass password for both MYsql and Postgres in the command line and if I have # in my password how to use it in the command because we already have user#localhost in the command.

From pgloader Reference Manual (https://pgloader.readthedocs.io/en/latest/pgloader.html):
command line:
pgloader SOURCE TARGET
Source Connection String
db://user:pass#host:port/dbname
Where db might be of sqlite, mysql or mssql.
Connection String
The parameter is expected to be given as a Connection URI as documented in the PostgreSQL documentation at http://www.postgresql.org/docs/9.3/static/libpq-connect.html#LIBPQ-CONNSTRING.
postgresql://[user[:password]#][netloc][:port][/dbname][?option=value&...]
user
Can contain any character, including colon (:) which must then be doubled (::) and at-sign (#) which must then be doubled (##).
When omitted, the user name defaults to the value of the PGUSER environment variable, and if it is unset, the value of the USER environment variable.
password
Can contain any character, including the at sign (#) which must then be doubled (##). To leave the password empty, when the user name ends with at at sign, you then have to use the syntax user:#.
When omitted, the password defaults to the value of the PGPASSWORD environment variable if it is set, otherwise the password is left unset.
When no password is found either in the connection URI nor in the environment, then pgloader looks for a .pgpass file as documented at https://www.postgresql.org/docs/current/static/libpq-pgpass.html

Related

ERROR 1130 (HY000): Host 'localhost' is not allowed to connect to this MySQL server

So I am stuck with this error when trying to connect my node.js application with MySQL.
It won't let me connect to MySQL from localhost, not a single command is working.
The MySql workbench also says the same
I can't use any database commands since it's not letting me access mysql. Gone through almost all possible solutions on the internet none of them worked. Please help me out here even an explanation for this would help if not the solution.
In order to access you must do the following steps :
1. Run the terminate with user permission.
2. Access the path where you have mysql installed.
3. Put the following sentence.
mysql.exe -u root -ppasw
-u : It is the user.
-p : the password but next to the p without space.
If it does not work try this in windows cmd
To restore to a single concrete database.
mysqlbinlog -database='yourFile.00004'
Explanation : The Binary log.
It has replaced the old update file.
Its mission is to update the DBs during a recovery operation.
Replication masters are used as a reminder of the statements to be sent to the slave servers.
If the name is not specified, the host is chosen.
Performance drop of 1%.
Active bins must not be opened during execution.
If you put extension to the file, it is ignored.
A new BIN_LOG file is created when :
The server is restarted
A Flush binary Logs is made
The size specified in MAX_BINLOG_SIZE is exceeded.
The files that are generated have an extension that are sequential numbers and represent the order (index) of their creation controlled by the name host_name.index.
To activate and decomment the log-bin my.ini directive. If log-bin=file is used, that name will be used to name the sequence of files.
To delete index files.
purge binary before date-time (in this format "yyyy-mm-dd hh:mm:ss" or now() or interval....)
purge binary logs to filename; deletes up to this file (this one not included)
reset master -> deletes all files
To disable the binary log, the session variable is used.
SQL_LOG_BIN : Up to version 5.6 this one is
EXECUTE DB : binlog-do-db=BD
DOES NOT RUN DB : binlog-ignore-db=BD
The commands are the continuation of the binary log.
create database
alter database
drop database
To see the content of a binary file (must not be open).
mysqlbinlog "file with its path".
To restore several binary files must be done in one step.
mysqlbinlog file1 file2 file3 file3 | mysql -u root -ppassword
To restore.
Overwrite the file >
Adds in the content respecting the content >>
To restore to a single concrete database.
mysqlbinlog -database='filenamebinlog.00004'
If the above does not work, do this first
Another option
ERROR 1130 (HY000): Host 'localhost' is not allowed to connect to this MySQL server
Cause :
mysql only has one root user, select MD5 after changing root password, then submit, reboot.
Login appears "The host 'localhost' is not allowed to connect to this MySQL server..."
Try the user table in another mysql library, overwrite, no, it is estimated that the version is different
Resolve :
Edit my.ini
Add a sentence to [mysqld]: skip-grant-tables
For example :
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-name-resolve
skip-grant-tables
The purpose is :
Bypass MySQL access control, anyone can log in to the MySQL database as an administrator in the console.
It should be noted that after changing the password, the MySQL server must be stopped and restarted to take effect.
Restart the mysql service!

MySQL CLI Client shows data as Hex

My MySQL CLI client when connecting to a database is automatically showing the data as hex
Connecting in CLI using mysql -u user -p'password' -h host -P port --ssl-mode=DISABLED
To turn this off I have to run it with the --skip-binary-as-hex option to see the data properly
Need help understanding what is causing this is getting enabled by default.
This issue does not exist for other users logging into the same database and is not an issue for me I connect through a DB tool, it occurs only on CLI
Prior to MySQL 8.0.19, the issue which you are facing did not exist. binary-as-hex client option is enabled by default from MySQL 8.0.19 Command Line Client.
Run status or \s in MySQL Command Line Client. You will notice a line about binary data like this:
Binary data as: Hexadecimal
You can refer these links for more information:
https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char
https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html#option_mysql_binary-as-hex

Configure MySQL in SublimeText 3

I want to configure MySQL in SublimeText 3, I found that the configuration is from Build System / New Build System ...
My written code is as follows:
{
"cmd": ["C: /xampp/mysql/bin/mysql.exe", "-u", "dorbezo", "-P", "Dorbezo123", "-h", "192.168.1.99", " -e "," source $ file "," -t "],
"selector": "source.sql",
"quiet": true}
My credentials to access MySQL from Workbench are the following:
user: dorbezo,
pass: Dorbezo123,
host: port: 192.168.1.99:3306
Am I entering the connection correctly? It is worth mentioning that I connect via VPN and I have ** xampp ** started when I try to run a query, getting the following error:
** show databases; **
Unknown suffix 'D' used for variable 'port' (value 'Dorbezo123')
C: /xampp/mysql/bin/mysql.exe: Error while setting value 'Dorbezo123' to 'port'
I also mention that the port where ** xampp ** connects is 3307, since 3306 (which I use in Workbench) causes me conflict.
There are several problems with your .sublime-build file.
Your command path "C: /xampp/mysql/bin/mysql.exe" has a space in it but perhaps that was pasted into your post incorrectly. I would have expected something more like this on Windows: "C:\\xampp\\mysql\\bin\\mysql.exe".
You are using an uppercase -P for your password, it should be a lowercase -p.
You possibly need to add the port number with the uppercase "-P", "3306". I say 'possibly' because 3306 is the default port for MySQL so you may not need to specify it at all.
Using long form options is generally a good idea because they prevent letter case mistakes. e.g. --user, --password, --host, --port, --execute, --table.
Here is a MySQL.sublime-build file for you to try, the long options (with my details) work for me on Linux:
{
"cmd": ["C:\\xampp\\mysql\\bin\\mysql.exe", "--user=dorbezo", "--password=Dorbezo123", "--host=192.168.1.99", "--port=3306", "--execute=source $file", "--table"],
"selector": "source.sql"
}
Clearly storing a password in a .sublime-build file is a security risk. You should consider creating a MySQL user with an insecure password which has limited privileges.
There is also the SQLTools Sublime Text plugin which you could install, see here for the documentation. Instead of your connection details being stored in a .sublime-build file you would add them in a SQLToolsConnections.sublime-settings settings file. The documentation link above has detailed examples. I suspect you might find using this plugin easier than managing the build file. Using this plugin means there is less of a password security issue; if you use null in the password field (not in quotes) then the plugin will prompt for the password and then remember it for the session (I think).

Error while installing Koha

I get this error when installing via the web installer, the error says:
DBIx::Class::Storage::DBI::_dbh_execute(): Data truncated for column 'type' at row 1 at /usr/share/koha/lib/Koha/Objects.pm line 101
Installed version is: 16.05.05.000
I installed using packages by following the instructions on this link: https://wiki.koha-community.org/wiki/Koha_on_Debian
The database I'm using is: MySQL database; and it is on the same machine as Koha.
Any idea please!
I was presented with the same error. It appears that the error is given in an enum column in the database. For MySQL you can solve it as follows (inside the MySQL database administrator):
SET GLOBAL sql_mode = '';
When setting the mode with an empty string '' you are telling MySQL not to take into account some errors that arise when inserting data.
MySQL can operate in different modes, some modes are more restrictive than others, for example, some modes do not allow certain operations, such as division by zero or restrict the way in which the dates are represented in the database.
To see how the server is, you must log into MySQL from the command line:
mysql -u root -p
If the MySQL server does not have a password (which is not recommended), omit the -p parameter. You can then check the mode with the following command
SELECT ##GLOBAL.sql_mode;
It will return more or less similar to this:
STRICT_TRANS_TABLES, NO_ENGINE_SUBSTITUTION
You can find more information on this at http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html
Source
install phpmyadmin on different port (say 81)
select koha_library database (where library is the instance)
select ‘search_filed’ table
press ‘structure’ tap
select 'type' column and then press 'change'
change the type to varchar and length to 255 (or you can change the type of column 'type'in table ‘search_filed’ from enum to varchar(255) using the terminal)
execute the following command in server terminal (login using mysql-u root -p ):
SET GLOBAL sql_mode='';
quit;
sudo service mysql restart && sudo service apache2 restart

How to special the mysql sock path in clsql?

When I connected to mysql using clsql,the following error occurred
While trying to connect to database localhost:3306/root/
using database-type MYSQL:
Error 2002 / Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)
has occurred.
[Condition of type SQL-CONNECTION-ERROR]
My mysql.sock path is "/home/myhome/var/run/mysql/mysql.sock",how
can I change the default sock path in clsql?
Here is my code, (SBCL 1.0.50 ,mysql 5.0,clsql-20130128-git)
(asdf:operate 'asdf:load-op 'clsql)
(in-package #:clsql-user)
(clsql:connect '("localhost" "username" "password" "dbname" 3306 ) :database-type :mysql)"
I would suggest creating a ~/.my.cnf or (if you have root access) /etc/my.cnf file and including a client setting for the socket, libmysqlclient might pick this up.
Failing that (or if you don't want to make a global change) the doc suggests you can specify a list of MySQL options as a separate assoc list http://clsql.b9.com/manual/connect.html which get passed into mysql_options()
Funny,the answer is that change the host from "localhost" to "127.0.0.1"