How to enable federated engine in mysql? Missing my.cnf file - php

I have found multiple solutions on stackoverflow, however none seemed to work as I don't have the my.cnf file, (except under the mysql folder I have one, but it doesnt have [mysqld] section.) Not really sure what else to check.
I just purchased a server. I have installed,
-apache
-mysql
-php
-phpmyadmin
all on Ubuntu 20.10 x64
Trying to create a link between this server and another server.

I was able to find it myself. It is under the folder:
/etc/mysql/mysql.conf.d
File Name: mysqld.cnf
I then proceeded with adding federated to the below info:
[mysqld]
#
# * Basic Settings
#
user = mysql
# pid-file = /var/run/mysqld/mysqld.pid
# socket = /var/run/mysqld/mysqld.sock
# port = 3306
# datadir = /var/lib/mysql
federated

Related

Not able to connect to DB in php with mariadb gssapi, authentication method unknown to client

I am trying to auth users with gssapi using mariadb gssapi plugin in php on a local installation with xampp. I have set up xampp and a local installation which works. Now i want to connect to the db by using the windows ldap user and gssapi authentication.
the problem was somehow discuessed here, but without any results:
GSSAPI-Auth with PHP to MariaDB (Windows)
the gssapi authentication for the mariadb seems to work. I created a user in phpmyadmin with authentication method = gssapi. In the CLI i am able to connect, see picture below:
Successful mysql connect with domain user
now when trying to connect with
if (($dbcon=mysqli_connect("localhost","$mysql_userid","$password"))===FALSE) {
exit("4:Login process failed while connecting to database");
echo "Debug-Fehlermeldung: " . mysqli_connect_error . PHP_EOL;
}else{
$auth_result=TRUE;
}
i am getting the following error:
Warning: mysqli_connect(): The server requested authentication method unknown to the client [auth_gssapi_client] in C:\xampp\htdocs\oa5-maria\trunk\login.php on line 82
Warning: mysqli_connect(): (HY000/2054): The server requested authentication method unknown to the client in C:\xampp\htdocs\oa5-maria\trunk\login.php on line 82
4:Login process failed while connecting to database
I have set the default-authentication-plugin=gssapi in the my.ini file. But i have no idea if this is the correct approach.
Do you have any suggestions to solve that problem?
This is my my.ini file:
# Example MySQL config file for small systems.
#
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it's important that the mysqld daemon
# doesn't use much resources.
#
# You can copy this file to
# C:/xampp/mysql/bin/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is C:/xampp/mysql/data) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
# password = your_password
port=3306
socket="C:/xampp/mysql/mysql.sock"
# Here follows entries for some specific programs
# The MySQL server
default-character-set=utf8mb4
[mysqld]
port=3306
socket="C:/xampp/mysql/mysql.sock"
basedir="C:/xampp/mysql"
tmpdir="C:/xampp/tmp"
datadir="C:/xampp/mysql/data"
pid_file="mysql.pid"
# enable-named-pipe
key_buffer=16M
max_allowed_packet=200M
sort_buffer_size=512K
net_buffer_length=8K
read_buffer_size=256K
read_rnd_buffer_size=512K
myisam_sort_buffer_size=8M
log_error="mysql_error.log"
#neu für authentifizierung
default-authentication-plugin=gssapi
# Change here for bind listening
# bind-address="127.0.0.1"
# bind-address = ::1 # for ipv6
# Where do all the plugins live
plugin_dir="C:/xampp/mysql/lib/plugin/"
# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
# commented in by lampp security
#skip-networking
#skip-federated
# Replication Master Server (default)
# binary logging is required for replication
# log-bin deactivated by default since XAMPP 1.4.11
#log-bin=mysql-bin
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id =1
# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
# the syntax is:
#
# CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
# MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
# where you replace <host>, <user>, <password> by quoted strings and
# <port> by the master's port number (3306 by default).
#
# Example:
#
# CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
# MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
# start replication for the first time (even unsuccessfully, for example
# if you mistyped the password in master-password and the slave fails to
# connect), the slave will create a master.info file, and any later
# change in this file to the variables' values below will be ignored and
# overridden by the content of the master.info file, unless you shutdown
# the slave server, delete master.info and restart the slaver server.
# For that reason, you may want to leave the lines below untouched
# (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id = 2
#
# The replication master for this slave - required
#master-host = <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user = <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password = <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port = <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin
# Point the following paths to different dedicated disks
#tmpdir = "C:/xampp/tmp"
#log-update = /path-to-dedicated-directory/hostname
# Uncomment the following if you are using BDB tables
#bdb_cache_size = 4M
#bdb_max_lock = 10000
# Comment the following if you are using InnoDB tables
#skip-innodb
innodb_data_home_dir="C:/xampp/mysql/data"
innodb_data_file_path=ibdata1:10M:autoextend
innodb_log_group_home_dir="C:/xampp/mysql/data"
#innodb_log_arch_dir = "C:/xampp/mysql/data"
## You can set .._buffer_pool_size up to 50 - 80 %
## of RAM but beware of setting memory usage too high
innodb_buffer_pool_size=16M
## Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size=5M
innodb_log_buffer_size=8M
innodb_flush_log_at_trx_commit=1
innodb_lock_wait_timeout=50
## UTF 8 Settings
#init-connect=\'SET NAMES utf8\'
#collation_server=utf8_unicode_ci
#character_set_server=utf8
#skip-character-set-client-handshake
#character_sets-dir="C:/xampp/mysql/share/charsets"
sql_mode=NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_ENGINE_SUBSTITUTION
log_bin_trust_function_creators=1
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
[mysqldump]
max_allowed_packet=16M
[mysql]
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[isamchk]
key_buffer=20M
sort_buffer_size=20M
read_buffer=2M
write_buffer=2M
[myisamchk]
key_buffer=20M
sort_buffer_size=20M
read_buffer=2M
write_buffer=2M
[mysqlhotcopy]
lower_case_table_names=0
The difference between your client and PHP is, that the client is linked against libmariadb (and is therefore able to load the auth_gssapi_plugin, while mysqli is either linked against libmysql or PHP's internal mysqlnd driver.
Beside Kerberos/GSSAPI MariaDB also provides ed25519 and pam authentication (via dialog plugin) which is not supported by libmysql and mysqlnd.
Building ext/mysqli against MariaDB Connector/C unfortunately doesn't work and recent pull requests which fixed that problem were rejected.

Can't access mysql database after changing its directory

I am trying to connect to a mysql database and I keep getting this error:
pi#raspberrypi /var/lib/mysql $ sudo mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
After moving my database files onto an external flash drive (/media/my_flashdrive), then moving everything back to /var/lib/mysql:
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock #ORIGINAL
#socket = /media/my_flashdrive/mysqldb/mysqld.sock #ADDED
port = 3306
basedir = /usr
datadir = /var/lib/mysql #ORIGINAL
#datadir = /media/my_flashdrive/mysqldb #ADDED
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1 ###CHANGED
The permissions on all files inside the mysql folder are root. Can someone explain what I did wrong here?

mysql is not picking up the my.cnf in linux

I have got an environment with in Linux with mysql 5.5 + wordpress + php 5.6 + phpmyadmin
I have found out that no matter what value of system variable / option changed in the phpmyadmin will be reset after service / server restart
Also, none of the options in the /etc/my.cnf is being picked up
How would I be possible to resolve this problem?
location of my.cnf = /etc/my.cnf
mysql datadir = /var/lib/mysql

I am unable to use MySQL due to a "refused connection"

I am trying to run the no-install version of MySQL on Windows XP located in C:/mysql/ on my machine.
The error message I receive within a PHP file when I try to connect to MySQL reads.
Could not connect: No connection could be made because the target machine actively refused it
I have edited the config file my.ini and altered/added the following.
[client]
port = 3306
socket = C:/mysql/tmp/mysql.sock
[mysqld]
port = 3306
socket = C:/mysql/tmp/mysql.sock
basedir = C:/mysql/
datadir = C:/mysql/data/
bind-address = 127.0.0.1
skip-networking
enable-named-pipe
When I run mysqld.exe I can confirm it is running within command prompt tasklist.
However when I try cmd netstat -a I cannot see any port usage at 3306.
Inside MySQL error logs, it reads.
140411 13:30:34 [Note] c:\mysql\bin\mysqld.exe: ready for connections.
Version: '5.5.37-log' socket: '' port: 0 MySQL Community Server (GPL)
The port: 0 doesn't look correct to me, but I am not sure.
When I run mysql.exe direct in cmd I get the following returned
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
Some things I have tried already.
Placing a copy of my.ini in C:/WINDOWS and also a copy within C:/mysql
Changing bind-address = 127.0.0.1 to bind-address =
localhost
Inside PHP file MySQL connection variants, localhost, 127.0.0.1, 127.0.0.1:3306 inside basic mysql_connect()
Created tmp/mysql.sock file (in case dir + file not existing matters)
Commented out skip-networking in my.ini
After running mysqld.exe whilst running ran mysqladmin.exe in cmd which returns 'Can't connect to MySQL server at 'localhost'
Running telnet localhost 3306 returns
'Connecting To localhost...Could not open connection to the host, on port 3306: C
onnect failed'
Commented out bind-address in my.ini to allow default settings.
Ran mysqld.exe with user root (-u root) also inserted user = root in my.ini
Set Windows Firewall to off.
Thanks in advance.
Ok. You have binded your server to specific ip so please read this MySQL bind-addres. Please unbind your server and check if you have proper user. (last paragraph in documentation)

MySQL working with 127.0.0.1 but not working with localhost?

I have a strange problem in php MySQL:
php connects with 127.0.0.1 but not with localhost.
How to solve this issue?
Try ping localhost in a command line, it may be resolving to ::1: the IP6 equivalent to 127.0.0.1
To fix it, add (or uncomment) the line:
127.0.0.1 localhost
in C:\WINDOWS\system32\drivers\etc\hosts
localhost must be defined in your hosts file, which it is by default on Windows and most OSs.
Check the following text file and see what's up:
C:\WINDOWS\system32\drivers\etc\hosts
Please note "hosts" is the file, no extension, it's not a folder. This file should be pretty much empty, if you see entries either your AV/spam blocker added a ton of entries that point to 127.0.0.1 or nasty malware has written garbage in there, despite, newer entries are below older ones. Localhost should be the first entry in that file.
For macs, here's the solution:
Connect to MySQL using localhost instead of 127.0.0.1 on a MAC. For a long while now I’ve been connecting to MySQL on my development platform with 127.0.0.1 because for some reason localhost didn’t work. Turns out it’s because 127.0.0.1 uses TCP/IP and localhost uses sockets. The php.ini file points to the wrong place for the mysql.sock so all you have to do is change it, restart apache and voila!
Open php.ini: /private/etc/php.ini
Find the following line: mysql.default_socket = /var/mysql/mysql.sock
Replace with: mysql.default_socket = /tmp/mysql.sock
Restart apache: apachectl restart
Note: Depending on your setup, you may also have to update these lines in your php.ini:
mysqli.default_socket = /tmp/mysql.sock
pdo_mysql.default_socket = /tmp/mysql.sock
Note: If you don’t have a php.ini file, you need to copy the provided default called php.ini.default
sudo cp /private/etc/php.ini.default /private/etc/php.ini
via http://madproject.com/general/connect-to-mysql-using-localhost-instead-of-127-0-0-1-on-a-mac/
Also have a look inside the mysql database which defines the user access privileges. You can define there from which source hosts a given user is allowed to connect. You can consult http://dev.mysql.com/doc/refman/5.1/en/connection-access.html for more details
I remember that being a longstanding and documented feature of Mysql on Windows. Something about the way local sockets work or something.
Try:
IE-->Tools-->Options--> Connection --> LAN Settings Check Bypass Proxy for local addresses
If MySQL connects to 127.0.0.1 it does so via TCP/IP whereas if it connects to localhost it does so via a socket.
Is PHP looking in the right place for mysql.sock? Make sure php.ini and my.conf have matching locations
Is localhost resolving to the IPv6 address, as opposed to the IPv4, and MySQL is not listening on the v4 address?
The solution is make localhost resolve to the v4 address, OR make MySQL listen on the v6 address.
If you not on windows also test if mysql is connecting via socket, locally it normally does.
Force tcp with the mysql client
mysql -usomeone -p --protocol=TCP
vs. socket (default on linux)
mysql -usomeone -p
mysql -usomeone -p --protocol=socket
The latter didn't work for my someone#127.0.0.1

Categories