I search the web for a 2 hours now trying to connect from my MacBook to mysql installed using brew on iMac.
I can login locally from the iMac on mysql:
From iMac terminal:
mac-server:5.6.26 mhewedy$ ifconfig | grep netmask
inet 127.0.0.1 netmask 0xff000000
inet 192.168.1.2 netmask 0xffffff00 broadcast 192.168.1.255
Mysql:
mysql> show grants for 'root';
+--------------------------------------------------------------------------------------------------------------------------------+
| Grants for root#% |
+--------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY PASSWORD '....' WITH GRANT OPTION
And my.cnf file
cat /usr/local/Cellar/mysql/5.6.26/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
bind-address = 0.0.0.0
# skip-networking
I am trying to connect from MysqlWorkbench from the macbook:
Related
Hello dear StackOverflow community,
I have a large WordPress site that now crashes the database by creating dozens of Creating sort index tasks with:
SELECT t.*, tt.*
FROM wp_terms AS t
INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id
WHERE tt.taxonomy IN ('categories')
ORDER BY t.name ASC
Those run for more than 20 seconds +. Afterwards its "sending data" with the same SQL query. The server is using an AMD epyc cpu and shouldn't have any problems (even though the database is large) and it did not have until it suddenly seems to be stuck.
Shouldn't it be caching this query anyways?
The mariadb my.cf config looks like:
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /run/mysqld/mysqld.pid
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
lc-messages = en_US
skip-external-locking
# Broken reverse DNS slows down connections considerably and name resolve is
# safe to skip if there are no "host by domain name" access grants
#skip-name-resolve
# 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
#
# * Fine Tuning
#
#key_buffer_size = 128M
#max_allowed_packet = 1G
#thread_stack = 192K
#thread_cache_size = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
#myisam_recover_options = BACKUP
#max_connections = 100
#table_cache = 64
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# Recommend only changing this at runtime for short testing periods if needed!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
# When running under systemd, error logging goes via stdout/stderr to journald
# and when running legacy init error logging goes to syslog due to
# /etc/mysql/conf.d/mariadb.conf.d/50-mysqld_safe.cnf
# Enable this if you want to have error logging into a separate file
#log_error = /var/log/mysql/error.log
# Enable the slow query log to see queries with especially long duration
#slow_query_log_file = /var/log/mysql/mariadb-slow.log
#long_query_time = 10
#log_slow_verbosity = query_plan,explain
#log-queries-not-using-indexes
#min_examined_row_limit = 1000
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
#max_binlog_size = 100M
# * Character sets
#
# MySQL/MariaDB default is Latin1, but in Debian we rather default to the full
# utf8 4-byte character set. See also client.cnf
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
# Most important is to give InnoDB 80 % of the system RAM for buffer use:
# https://mariadb.com/kb/en/innodb-system-variables/#innodb_buffer_pool_size
#innodb_buffer_pool_size = 8G
# this is only for embedded server
[embedded]
# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
# This group is only read by MariaDB-10.5 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.5]
I restarted mariadb, but the advisor mentions a huge rate of opening tables (same for files). The server is running only for 15 minutes. Is this due to the short time or do I have to change the settings (before the huge amount of Creating sort index tasks, the server was stable)
Issue:
The rate of opening tables is high.
Recommendation:
Opening tables requires disk I/O which is costly. Increasing table_open_cache might avoid this.
Justification:
Opened table rate: 1.26 per second, this value should be less than 10 per hour
Used variable / formula:
Opened_tables / Uptime
Test:
value*60*60 > 10
I would be awesome if somebody has an idea, what to do about that problem
I have mysql on my localhost and I am able to log in with root:
[root#pocnnr1n1 etc]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 5.5.52-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
Now, I have a docker on this host which has ip address of '172.17.0.2'
There is no problem ping from docker to host:
root#eaa90c1059f2:/app/airflow/dags# ping 192.168.211.251
PING 192.168.211.251 (192.168.211.251): 56 data bytes
64 bytes from 192.168.211.251: icmp_seq=0 ttl=64 time=0.208 ms
From docker, if I manually run pymysql to create a connection:
conn= pymysql.connect(host='192.168.211.251', port=3306, user='root',
passwd='root', db='airflow')
I have the following error:
pymysql.err.OperationalError: (1045, "Access denied for user
'root'#'172.17.0.2' (using password: YES)")
If I change the ip address to '172.17.0.2' as below:
conn= pymysql.connect(host='172.17.0.2', port=3306, user='root',
passwd='root', db='airflow')
I have the following error:
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on
'172.17.0.2' ([Errno 111] Connection refused)")
Update:
my.cnf is as below:
[mysqld]
transaction-isolation = READ-COMMITTED
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links = 0
key_buffer = 16M
key_buffer_size = 32M
max_allowed_packet = 32M
thread_stack = 256K
thread_cache_size = 64
query_cache_limit = 8M
query_cache_size = 64M
query_cache_type = 1
max_connections = 550
#expire_logs_days = 10
#max_binlog_size = 100M
#log_bin should be on a disk with enough free space. Replace '/var/lib/mysql/mysql_binary_log' with an appropriate path for your system
#and chown the specified folder to the mysql user.
log_bin=/var/lib/mysql/mysql_binary_log
#explicit_defaults_for_timestamp = 1
binlog_format = mixed
read_buffer_size = 2M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
join_buffer_size = 8M
# InnoDB settings
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 64M
innodb_buffer_pool_size = 4G
innodb_thread_concurrency = 8
innodb_flush_method = O_DIRECT
innodb_log_file_size = 512M
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
This is from the mysql-doc
Make sure that the server has not been configured to ignore network
connections or (if you are attempting to connect remotely) that it has
not been configured to listen only locally on its network interfaces.
If the server was started with --skip-networking, it will not accept
TCP/IP connections at all. If the server was started with
--bind-address=127.0.0.1, it will listen for TCP/IP connections only locally on the loopback interface and will not accept remote
connections.
When something from the docker network try to connect the localhost: it's also trying to access the mysql from remote.
Find the my.cnf(usually /etc/mysql/my.cnf) comment the line bind-address=127.0.0.1
I just sorted out as below:
This issue is about the right privilege was not granted to the user airflow#172.17.0.2
What I need to do is on the host's mysql,
GRANT ALL TO 'airflow'#'172.17.0.2' IDENTIFIED BY 'airflow' ;
FLUSH PRIVILEGES;
This is very clear if you do: select User, Host, Password from mysql.user;
Now the connection can be created using pymysql.
For the convenience of testing, one does not have to test it within airflow dag, this can be tested using python only (but with pymysql imported)
Hope this help.
I'm using MySQL server version: 10.1.23-MariaDB-9+deb9u1 Raspbian 9.0 on a Raspberry Pi.
This is my /etc/mysql/my.cnf:
# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
# Import all .cnf files from configuration directory
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/
#bind-address = 0.0.0.0
I've tried this:
sudo mysql_secure_installation
Change root password: y
Password
Retyped password
Remove anonymous users: y
Disallow root login remotely: n
Remove test database: y
Reload priviledges: y
CREATE USER 'root'#'%.%.%.%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%.%.%.%' WITH GRANT OPTION;
FLUSH PRIVILEDGES;
service mysql restart
In my.cnf, with bind-address commented, I can access from localhost, but not from remote host using SQL Workbench.
With bind-address uncommented, I cannot access from localhost, but I can access from remote host using SQL Workbench, e.g.:
mysql -u root
mysql: unknown variable 'bind-address=0.0.0.0'
This is my users table:
MariaDB [(none)]> select user, host, password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| root | localhost | *054D119DEAD56E226D8356557796BFA72E71BA40 |
| root | %.%.%.% | *054D119DEAD56E226D8356557796BFA72E71BA40 |
| root | % | *054D119DEAD56E226D8356557796BFA72E71BA40 |
+------+-----------+-------------------------------------------+
How do I configure the server to allow local and remote access for root from any IP?
Add a line over bind-address = 0.0.0.0 with [mysqld] like:
[mysqld]
bind-address = 0.0.0.0
In your case both, the server and the local client, reads the bind address and the client want to connect to the IP 0.0.0.0
According to this link it seems that the mysql client doesn’t recognize the bind address.
In order to connect locally I have to use this line:
mysql --no-defaults -u[username] -p[password] [database]
Just in case - I first put the bind-address between the lines and it did not work after
systemctl restart mysqld
With bind-address at the end it worked:
# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
# Import all .cnf files from configuration directory
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/
[mysqld]
bind-address = 0.0.0.0
i've looked up every tutorial on how to fix this and nothing worked so far,
I'm getting this error
No connection could be made because the target machine actively refused it
i'm using linux centos7 mysql version
mysql Ver 14.14 Distrib 5.6.32, for Linux (x86_64) using EditLine wrapper
blow is my.cnf
also i had to create my own my.cnf as when i installed mysql it didn't have one located i put this into etc/my.cnf it's running the cnf as it's taken mysql out of strict mode.
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
bind-address = 0.0.0.0
#skip-networking
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Ok, I am assuming that you have installed this on a completely different machine (as opposed to a Virtual Host on your Windows box).
You need to make sure that port 3306 is open on your DB server first and foremost. You can check this with a port checker (there are plenty of free ones online).
Then, with the user you are trying to connect with, you need to make sure that user has access from the origin IP address (i.e. the IP on your Windows machine). This can be done with the following code from the mysql prompt.
GRANT ALL PRIVILEGES ON <your db name>.* TO <your user>#<your ip> IDENTIFIED BY '<your password>';
A less secure option would be to allow all inbound IPs by using the % wildcard.
After this you need to run the following command.
FLUSH PRIVILEGES;
That should be it.
I have downloaded MYSQL via:
bash <(curl -Ls http://git.io/eUx7rg)
Prior to installing I've completely uninstalled previous components via:
http://community.jaspersoft.com/wiki/uninstall-mysql-mac-os-x
I've had to modify permissions in order to see the log file and see primarily permissions errors. Also, when I try:
type mysql
The result, in terminal, points to a directory that does not exist on my local system. When I trace the path to the executable (via Finder) I get the following error in Terminal:
/usr/local/mysql-5.6.19-osx10.7-x86_64/bin/mysql ; exit;
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2)
logout
Also, when I look at my.conf file, everything is asterisked out:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
Had the same problem. Had to switch machines for a week and installing MySQL on "OS X 10.9.3 (13D65)" would not work. Had to wipe the account clean and reinitialize the user to get it going. Apparently there was still an old mysql which wasn't uninstalled completely. Google "uninstall mysql manually"
The access denied happens sometime when the grant is given to the interface 127.0.0.1 but not to localhost.
Try granting access to %, 127.0.0.1, and localhost.