How make mariadb federated with ssh - mysql

How make mariadb federated with ssh?
DROP SERVER IF EXISTS `any_server_name`;
CREATE SERVER ' any_server_name ' FOREIGN DATA WRAPPER 'mysql' OPTIONS
(HOST 'host.com',
DATABASE 'database_name',
USER 'user_name',
PASSWORD "password",
PORT 3306,
SOCKET '/var/lib/mysql/mysql.sock',
OWNER 'root');
DROP TABLE IF EXISTS federated_table_name;
CREATE TABLE federated_table_name (
column_1 INT(11) NOT NULL,
column_2 INT(11) NOT NULL,
column_3 VARCHAR(255),
...
column_n VARCHAR(256)
)
ENGINE="FEDERATED" DEFAULT CHARSET=utf8mb4
CONNECTION=' any_server_name /table_name';

MariaDB doesn't support SSH, so you can only tunnel a connection and connect to the port of tunneled connection.
If you meant TLS/SSL instead of SSH, the answer is also no. CONNECT and FEDERATED engines don't support secure connections yet. A solution to store the TLS/SSL parameter in the client.mariadb section of the configuration file will also not work, since the call which forces to read the configuration file is commented out in the source code.
If you need that feature, please file a task on MariaDB Issue tracker
A workaround for it would be to use table type ODBC and to pass the TLS/SSL parameters in the DSN.

Related

PHPMyAdmin not processing changes to table structure

I am trying to change a field type in a table. When I run the command
ALTER TABLE `accounts` CHANGE `goldinbank` `goldinbank` BIGINT(20) NOT NULL DEFAULT '0';
and click Save, the operation is not processed, and PMA returns to the table structure without making changes.
Server: Localhost via UNIX socket
Server type: MySQL
Server version: 5.7.38 - MySQL Community Server (GPL)
Protocol version: 10
OS: Ubuntu 20.04.4 LTS
Any ideas would be greatly appreciated.

Node-MySQL2 library can connect to MySQL 8 but not with MySQL 5.7

On my dev environment, I have installed MySQL 8.0 and built the app accordingly, But on the prod server, the MySQL version is 5.7 and my app fails to connect to the database.
I use the mysql2 package because I need the Async API (mysql2/promise) which is not available in mysql. I even tried to use mysql-await which was a port of mysql with added Async API, but after authenticating to the Database, it just fails to create tables.
What causes this? are there different authentication methods used in MySQL 8.0 and MySQL 5.7? If so, then what method is used by 5.7 and how could I configure the authentication method used in the mysql2 connection?
I connect to the Database like this:
db = await mysql.createConnection({
host: mysql_host,
user: mysql_user,
password: mysql_pass,
database: mysql_db
})
And create tables like this:
await db.query(
"CREATE TABLE IF NOT EXISTS form (ID int NOT NULL AUTO_INCREMENT, \
Name varchar(255), \
Email varchar(255), \
Phone varchar(15), \
Address varchar(255), \
Occupation varchar(50), \
PRIMARY KEY (ID))")
Yes, both have different authentication methods. And to solve this issue, the better choice is either to change the development MySQL 8 with MySQL 5.7 or change the production MySQL 5.7 with MySQL 8, otherwise, you may face some more bugs in production.

connecting MySQL server to NetBeans

I am trying to connect MySQL database in Netbeans and stuck at the very first step- connecting the database. My Database is working fine on the console - tried command mysqladmin -u root -p ping
and it says mysql id is alive. I have even created database from console.
Now when i register it in Netbeans
Server Host Name:localhost
Server Port:3306
Admin user : root
Admin password :<the password which works on console>
and Admin Properties:
Path to admin tool: C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqladmin.exe
Argument : <blank>
Path to start command:C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld.exe
Argument : --console <as suggested in http://forums.netbeans.org/topic12767.html>
Path to stop command:C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqladmin.exe
Argument : -u root shutdown
but i still get message:-
"MySQL Server at localhost:3306 [root] (disconnected)"
if i right click and select "start" or "connect" i get the message in taskbar -
Waiting for MYSQL Server to start...
for an infinite time.
Any help what am i doing wrong here???
Follow these 2 steps:
STEP 1 :
Follow these steps using the Services Tab:
Right click on Database
Create new Connection
Customize the New COnnection as follows:
Connector Name: MYSQL (Connector/J Driver)
Host: localhost
Port: 3306
Database: mysql ( mysql is the default or enter your database name)
Username: enter your database username
Password: enter your database password
JDBC URL: jdbc:mysql://localhost:3306/mysql
CLick Finish button
NB: DELETE the ?zeroDateTimeBehaviour=convertToNull part in the URL.
Instead of mysql in the URL, you should see your database name)
STEP 2 :
Right click on MySQL Server at localhost:3306:[username](...)
Select Properties... from the shortcut menu
In the "MySQL Server Properties" dialog select the "Admin Properties" tab
Enter the following in the textboxes specified:
For Linux users :
Path to start command: /usr/bin/mysql
Arguments: /etc/init.d/mysql start
Path to Stop command: /usr/bin/mysql
Arguments: /etc/init.d/mysql stop
For MS Windows users :
NOTE: Optional:
In the Path/URL to admin tool field, type or browse to the location of your MySQL Administration application such as the MySQL Admin Tool, PhpMyAdmin, or other web-based administration tools.
Note: mysqladmin is the MySQL admin tool found in the bin folder of the MySQL installation directory. It is a command-line tool and not ideal for use with the IDE.
Citations:https://netbeans.org/kb/docs/ide/mysql.html?print=yeshttp://javawebaction.blogspot.com/2013/04/how-to-register-mysql-database-server.html
We will use MySQL Workbench in this example. Please use the path of your installation if you have MySQL workbench and the path to MySQL.
Path/URL to admin tool: C:\Program Files\MySQL\MySQL Workbench CE 5.2.47\MySQLWorkbench.exe
Arguments: (Leave blank)
Path to start command: C:\mysql\bin\mysqld (OR C:\mysql\bin\mysqld.exe)
Arguments: (Leave blank)
Path to Stop command: C:\mysql\bin\mysqladmin (OR C:\mysql\bin\mysqladmin.exe )
Arguments: -u root shutdown (Try -u root stop)
Possible exampes of MySQL bin folder locations for Windows Users:
C:\mysql\bin
C:\Program Files\MySQL\MySQL Server 5.1\bin\
Installation Folder: ~\xampp\mysql\bin
Fist of all make sure your SQL server is running. Actually I'm working on windows and I have installed a nice tool which is called MySQL workbench (you can find it here for almost any platform ).
Thus I just create a new database to test the connection, let's call it stackoverflow, with one table called user.
SET #OLD_UNIQUE_CHECKS=##UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET #OLD_FOREIGN_KEY_CHECKS=##FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET #OLD_SQL_MODE=##SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
DROP SCHEMA IF EXISTS `stackoverflow` ;
CREATE SCHEMA IF NOT EXISTS `stackoverflow` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `stackoverflow` ;
-- -----------------------------------------------------
-- Table `stackoverflow`.`user`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `stackoverflow`.`user` ;
CREATE TABLE IF NOT EXISTS `stackoverflow`.`user` (
`iduser` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(75) NOT NULL,
`email` VARCHAR(150) NOT NULL,
PRIMARY KEY (`iduser`),
UNIQUE INDEX `iduser_UNIQUE` (`iduser` ASC),
UNIQUE INDEX `email_UNIQUE` (`email` ASC))
ENGINE = InnoDB;
SET SQL_MODE=#OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=#OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=#OLD_UNIQUE_CHECKS;
You can reduce important part to
CREATE SCHEMA IF NOT EXISTS `stackoverflow`
CREATE TABLE IF NOT EXISTS `stackoverflow`.`user` (
`iduser` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(75) NOT NULL,
`email` VARCHAR(150) NOT NULL,
PRIMARY KEY (`iduser`),
UNIQUE INDEX `iduser_UNIQUE` (`iduser` ASC),
UNIQUE INDEX `email_UNIQUE` (`email` ASC))
So now I have my brand new stackoverflow database. Let's connect to it throught Netbeans. Launch netbeans and go to the services panel
Now right click on databases: new connection.. Choose MySql connector, they already come packed with netbeans.
Then fill in the gaps the data you need. As shown in the picture add the database name and remove from the connection url the optional parameters as l?zeroDateTimeBehaviour=convertToNull . Use the right user name and password and test the connection.
As you can see connection is successful.
Click FINISH.
You will have your connection successfully working and available under the services.
check the context.xml file in Web Pages -> META-INF, the username="user" must be the same as the database user, in my case was root, that solved the connection error
Hope helps
I just had the same issue with Netbeans 8.2 and trying to connect to mySQL server on a Mac OS machine. The only thing that worked for me was to add the following to the url of the connection string: &serverTimezone=UTC (or if you are connecting via Hibernate.cfg.xml then escape the & as &) Not surprisingly I found the solution on this stack overflow post also:
MySQL JDBC Driver 5.1.33 - Time Zone Issue
Best Regards,
Claudio
in my cases, i found my password in glassfish-recources.xml under WEB-INF
Close NetBeans.
Stop MySQL Server.
Update MySQL (if available)
Start MySQL Server.
Open NetBeans.
If still doesn't connect, download MySQL Connector/J and add mysql-connector-java-[version].jar to your
classpath and also to your Webserver's lib directory. For instance, Tomcat lib path
in XAMPP is
C:\xampp\tomcat\lib.
Then repeat the steps again.
Download XAMPP
Run XAMPP server. Click on Start button in front of MY SQL. Now you can see that color is changed to green. Now, Click on Admin.The new browser window will be open. Copy the link from browser and paste to the Admin properties as shown in below.
Set path in the admin properties of database connection.
Click on OK. Now your database is connected.
enter image description here
NETBEANS
koneksi
dbmSET #OLD_UNIQUE_CHECKS=##UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET #OLD_FOREIGN_KEY_CHECKS=##FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET #OLD_SQL_MODE=##SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';

Cannot import database using PhpMyAdmin with Cpanel on a VPS?

I have a recently set up VPS with cPanel.
I've made a user and created a database, and now I would like to import a database onto it.
However, when I try I get the error message
#1044 - Access denied for user 'user'#'localhost' to database 'database'
I suspect that this can be fixed with WHM, but I do not feel like trial and error just yet.
How would I go about fixing this?
When you import a database using phpMyAdmin, normally you do so by importing a text file with a .sql extension. Here is a section of code that may be in a .sql database backup. In your example, the database you are trying to import is named database.
-- phpMyAdmin SQL Dump
-- version 2.11.9.5
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Apr 02, 2010 at 08:01 AM
-- Server version: 5.0.81
-- PHP Version: 5.2.6
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE DATABASE database;
-- --------------------------------------------------------
--
-- Table structure for table `table`
--
CREATE TABLE IF NOT EXISTS `table` (
`column1` text NOT NULL,
`column2` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
When using phpMyAdmin to attempt to import such a file, you will receive an error message similar to:
Error
SQL query:
CREATE DATABASE database;
MySQL said: Documentation
#1044 - Access denied for user 'user'#'localhost' to database 'database'
In this scenario, the cPanel username is user. Because of cPanel's database naming conventions, all database names must begin with the cPanel username followed by _. Using this format you can only creat a database named user_database.
The reason this import failed is because of the following line in the .sql file...
CREATE DATABASE database;
Again, you cannot create a database named database, however you can create a database named user_database.
If you change the line that says: CREATE DATABASE so that it creates: user_database instead of database it will again fail with the following message:
Error
SQL query:
CREATE DATABASE user_database;
MySQL said: Documentation
#1044 - Access denied for user 'user'#'localhost' to database 'user_database'
When using cPanel, databases must be created within the cPanel itself.
Here are the steps to correct thi sissue:
Create the user_database database within cPanel
Comment out the CREATE DATABASE command in my .sql file
To do this, simply change:
CREATE DATABASE database;
to
-- CREATE DATABASE database;
You are simply adding dash-dash-space to the front of the line to comment it out so that it will not be executed.
Log into phpMyAdmin, access the user_database database, and then import as normal.
Before dumping your database, grant full access to your new database user created in Cpanel by the same password of that user:
grant all on database_name.* to database_user#localhost identified by 'password';
Then you need to modify your .sql file (can use notepad++), comment out the part where says create and use the new database:
-- Database: dbname
--
-- CREATE DATABASE IF NOT EXISTS dbname DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
-- USE dbname;
then you should be able to import it to your Cpanel.
To make it official...
The file you're attempting to import probably has something that you don't have permissions for. I would check permissions, then the file you're importing.

How to get started with PostgreSQL similar to MySQL

I am not getting a clue to:
simply login to postgreSQL
Create a database
Add a table
Insert a record
Delete , update etc
These things are normally very very easy using mysql . Can someone help me setup following alternative for postgresql
a) Reset default password -- Very Clean description ,
I do not find same level of clarity for PostgreSQL
(Any documentation link is highly appreciated)
b) We know the superuser for mysql is "root" what is the same for PostgreSQL
c) from command line how to ( PostgreSQL ones ?):
mysql -uroot -proot
create database testdb;
use testdb;
create table test(id int(11) auto_increment, name varchar(20), primary key(id));
insert into test(name) values("testing one"),("testing two"),("testing three"),("testing four");
select * from test;
update test set name=concat(name,now()) where id =3;
delete from test where id =4;
drop table if exists test;
drop database if exists testdb;
EDIT MAC OS
# Default password reset
sudo mate /Library/PostgreSQL/9.2/data/pg_hba.conf
replaced (md5 with trust)
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
with
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
save
executed the Reload Configuration.app
login to postgresql without password :
$ psql -U postgres
postgres# ALTER USER postgres WITH PASSWORD 'new password';
\q
-revert back all the changes in pg_hba.conf (replace trust with md5) and save
-reload configuration
Now I can login to postgresql with new password
psql -U postgres
Password for user postgres:[my new password]
To login:
psql -d postgres_dbname -U postgres
Create Database:
create database testuser;
\c testuser; /*use testuse as mysql*/
Create Table:
create table employee (Name char(20));
Insert :
insert into employee VALUES ('XAS');
Update Link
Delete Link
Reset Password : See Here &
See Here Too
Simply login to postgreSQL
psql -U postgres -W template1
-U = username
postgres is root
-W = ask for password
tempalte1 = default database
Create a database
-- Create the database from within postgresql
create database my_database_name
-- Connect to the database
\c my_database_name
-- Create the database without logging in
createdb -U postgres -W my_database_name
Add a table
Insert a record
Delete , update etc
All the above from 3 to 5 are like in MySQL
For resetting postgres forgotten password this link is a good reference.
postgresql is a completely different system than mysql; so do not assume things will be like mysql. They are completely different animals entirely; some of your SQL statements might not work, especially if you are using a MySQL proprietary command.
To login to postgresql, use the psql command shell
CREATE DATABASE
CREATE TABLE
INSERT
For all other basic SQL commands, consider going through the tutorial
User access control is something more fine grained and detailed in postgresql. There are users and roles. A user is simply a role that has the ability to login (like MySQL), but in postgresql you can have roles (an account) that cannot login.
What access a role has is defined in pg_hba.conf. This file defines if a role can login at all, by what means are they authenticated, from where they can login and what database they have access to.
ALTER USER is used to reset credentials.
The "root user" for postgresql is typically postgres; and this is a system user that is created during the install process. For Windows, the binary installer will ask if you want to launch the service as this user as well.
Please take a look at this PostgreSQL error 'Could not connect to server: No such file or directory'
Try to install postgresApp, this solved my problem which was the same of yours.