MySQL ?

MySQL Connection refused Access denied,

Solutions

MySQLRecommended

# MySQL systemctl status mysql
# service mysql status #, systemctl start mysql # ss -tlnp | grep 3306
# netstat -tlnp | grep 3306 # MySQL tail -50 /var/log/mysql/error.log

MySQL. and,.

:

andRecommended

# Access denied # 1. root mysql -u root -p # 2. SELECT user, host, authentication_string FROM mysql.user; # 3. host -- 'app'@'localhost' -- 'app'@'192.168.1.%' -- 'app'@'%' # 4. ()
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword123!';
FLUSH PRIVILEGES; # 5. SHOW GRANTS FOR 'app_user'@'%';

Access denied host. MySQL user@host, 'app'@'localhost' and 'app'@'%'.

: Access denied for user

and

# 1. MySQL 127.0.0.1()
grep bind-address /etc/mysql/mysql.conf.d/mysqld.cnf
# 127.0.0.1, 0.0.0.0 # bind-address = 0.0.0.0 # 2. MySQL
systemctl restart mysql # 3. # Ubuntu/Debian
ufw status
ufw allow 3306/tcp # CentOS/RHEL
firewall-cmd --list-ports
firewall-cmd --permanent --add-port=3306/tcp
firewall-cmd --reload # 4. telnet db-server 3306
# nc -zv db-server 3306

MySQL 3306. MySQL and.

:

# and SHOW VARIABLES LIKE 'max_connections';
SHOW STATUS LIKE 'Threads_connected'; # -- SET GLOBAL max_connections = 500; -- SHOW PROCESSLIST; -- SELECT CONCAT('KILL ', id, ';')
FROM information_schema.PROCESSLIST
WHERE COMMAND = 'Sleep' AND TIME > 300; -- (my.cnf)
-- [mysqld]
-- max_connections = 500
-- wait_timeout = 300

max_connections, New.,.

: Too many connections

MySQL 3306
bind-address and
root

Related Commands