简体   繁体   English

移动数据库目录 | 无法从本地主机或轮询器通过默认端口 3306 访问 mysql

[英]Moved database dir | Can't acess mysql through default port 3306 from localhost or poller

WORK: The only way I can localy acess is to specify the locaction dir of the database in DATABASE_PORT ex:工作:我可以本地访问的唯一方法是在 DATABASE_PORT 中指定数据库的位置目录,例如:

$database_type     = 'mysql';
$database_default  = 'database';
$database_hostname = 'localhost';
$database_username = 'cacti';
$database_password = 'password';
$database_port     = 'common/mysql/mysql.socket';
$database_retries  = 5;
$database_ssl      = false;
$database_ssl_key  = '';
$database_ssl_cert = '';
$database_ssl_ca   = '';

DOES NOT WORK: Cacti is trying to connect the database but it can't reach like this:不起作用:Cacti 正在尝试连接数据库,但无法像这样访问:

$database_type     = 'mysql';
$database_default  = 'database';
$database_hostname = 'localhost';
$database_username = 'cacti';
$database_password = 'password';
**$database_port     = '3306';**
$database_retries  = 5;
$database_ssl      = false;
$database_ssl_key  = '';
$database_ssl_cert = '';
$database_ssl_ca   = '';

NOT WORKING: Remote Poller不工作:远程轮询器

$rdatabase_type     = 'mysql';
$rdatabase_default  = 'database_main';
$rdatabase_hostname = 'remote_host';
$rdatabase_username = 'cacti';
$rdatabase_password = 'password';
$rdatabase_port     = '3306'
$rdatabase_retries  = 5;
$rdatabase_ssl      = false;

How I moved the database:我如何移动数据库:

First check the default dir:首先检查默认目录:

MariaDB [(none)]> select @@datadir;

Output
+-----------------+
| @@datadir       |
+-----------------+
| /var/lib/mysql/ |
+-----------------+
1 row in set (0.00 sec

Stoped process:停止进程:

sudo systemctl stop mysqld

Rsynk the default database dir to the new location将默认数据库目录重新同步到新位置

sudo rsync -av /var/lib/mysql /common/

Rename old mysql重命名旧 mysql

sudo mv /var/lib/mysql /var/lib/mysql.bak

Edit my.conf fie:编辑 my.conf 文件:

    sudo vi /etc/my.cnf
    [mysqld]
    . . .
    datadir=/common/mysql
    socket=/common/mysql/mysql.sock
    . . .

start mysql:启动 mysql:

sudo systemctl start mysqld

New location datadir;新的位置数据目录;

MariaDB [(none)]> select @@datadir;
+----------------+
| @@datadir      |
+----------------+
| /common/mysql/ |
+----------------+
1 row in set (0.000 sec
MariaDB [(none)]> SHOW VARIABLES WHERE Variable_name = 'port'
    -> ;
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port          | 3306  |
+---------------+-------+
1 row in set (0.001 sec)

Problem solved:问题解决了:

my.conf我的.conf

[client-server] port=3306 [客户端-服务器] 端口=3306

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即使 mysqld 在端口 3306 上运行,也无法连接到“localhost:3306”上的 MySQL 服务器 - Can't connect to MySQL server on 'localhost:3306' even though mysqld is running on port 3306 找不到 MySql 端口 3306 - Can't find MySql port 3306 无法启动MySQL,3306端口忙 - Can't start MySQL, port 3306 busy Django-默认端口0而不是3306-无法连接到'127.0.0.1'上的MySQL服务器(61) - Django - default port 0 instead of 3306 - Can't connect to MySQL server on '127.0.0.1' (61) 我无法使用mysql端口号3306访问数据库并在laravel项目中迁移 - I can't access database and migrate in laravel project using port number 3306 for mysql 如何将mysql的默认端口从3306更改为3360 - How to change the default port of mysql from 3306 to 3360 使用IPTABLES将MySQL 3306端口限制为localhost - Restricting MySQL 3306 port to localhost with IPTABLES 如何修复'无法连接到'localhost:3306'上的MySQL服务器'错误 - How to fix 'Can't connect to MySQL server on 'localhost:3306' error Docker - 无法使用 Prisma 服务访问 `localhost`:`3306` 的数据库服务器 - Docker - Can't reach database server at `localhost`:`3306` with Prisma service 无法通过 3306 端口连接到远程 MYSQL 服务器 - Can't Connect to the remote MYSQL server via 3306 port
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM