[MySQL FAQ]系列 -- 启用GTID & binlog新安装完的MySQL提示无法
问:刚刚新安装的MySQL,提示下面信息,无法登入,怎么回事? [root@imysql mysql]# mysql mysqlERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 答:数据库已经执行过 mysql_install_db 初始化了,按理说应该没问题。
问:刚刚新安装的MySQL,提示下面信息,无法登入,怎么回事?
[root@imysql mysql]# mysql mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
答:数据库已经执行过 mysql_install_db 初始化了,按理说应该没问题。经过排查,发现 $datadir 的 mysql 数据库目录的权限模式为:
drwx------ 2 mysql root 4096 Jan 9 20:22 mysql
看起来没有问题。检查错误日志,发现一行:
130109 21:04:23 [Warning] Bootstrap mode disables GTIDs. Bootstrap mode should only be used by mysql_install_db which initializes the MySQL data directory and creates system tables. ERROR: 1785 Updates to non-transactional tables are forbidden when DISABLE_GTID_UNSAFE_STATEMENTS = 1. 130109 21:04:23 [ERROR] Aborting
同时,mysql库下的user表空间文件显示:
-rw-rw---- 1 mysql mysql 10684 Jan 9 20:22 user.frm -rw-rw---- 1 mysql mysql 0 Jan 9 20:22 user.MYD -rw-rw---- 1 mysql mysql 1024 Jan 9 20:22 user.MYI
可以看到,user表空间数据文件大小为0。
看起来应该是和启用GTID模式有一定关系了。仔细检查下,发现和GTID相关的选项有:
gtid_mode = ON binlog_format = mixed disable-gtid-unsafe-statements = 1 log-bin=binlog
这是因为在启用GTID模式下,如果对非事务表更新时,无法保证事务一致性,因此设置 disable-gtid-unsafe-statements = 1 确保主从数据一致性。
解决方案:
这时候可以将选项 disable-gtid-unsafe-statements 的值修改为 0。也可以同时关闭 GTID 、 binlog 选项,初始化完毕后再打开。
#gtid_mode = ON #log-bin=binlog
或
disable-gtid-unsafe-statements = 0
技术相关:
MySQL基础知识
MySQL FAQ
原文地址:[MySQL FAQ]系列 -- 启用GTID & binlog新安装完的MySQL提示无法登录, 感谢原作者分享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

How to insert data into MySQL table? Connect to the database: Use mysqli to establish a connection to the database. Prepare the SQL query: Write an INSERT statement to specify the columns and values to be inserted. Execute query: Use the query() method to execute the insertion query. If successful, a confirmation message will be output.

Creating a MySQL table using PHP requires the following steps: Connect to the database. Create the database if it does not exist. Select a database. Create table. Execute the query. Close the connection.

The Xiaomi Mi 15 series is expected to be officially released in October, and its full series codenames have been exposed in the foreign media MiCode code base. Among them, the flagship Xiaomi Mi 15 Ultra is codenamed "Xuanyuan" (meaning "Xuanyuan"). This name comes from the Yellow Emperor in Chinese mythology, which symbolizes nobility. Xiaomi 15 is codenamed "Dada", while Xiaomi 15Pro is named "Haotian" (meaning "Haotian"). The internal code name of Xiaomi Mi 15S Pro is "dijun", which alludes to Emperor Jun, the creator god of "The Classic of Mountains and Seas". Xiaomi 15Ultra series covers

To use MySQL stored procedures in PHP: Use PDO or the MySQLi extension to connect to a MySQL database. Prepare the statement to call the stored procedure. Execute the stored procedure. Process the result set (if the stored procedure returns results). Close the database connection.

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

Since the Huawei Mate60 series went on sale last year, I personally have been using the Mate60Pro as my main phone. In nearly a year, Huawei Mate60Pro has undergone multiple OTA upgrades, and the overall experience has been significantly improved, giving people a feeling of being constantly new. For example, recently, the Huawei Mate60 series has once again received a major upgrade in imaging capabilities. The first is the new AI elimination function, which can intelligently eliminate passers-by and debris and automatically fill in the blank areas; secondly, the color accuracy and telephoto clarity of the main camera have been significantly upgraded. Considering that it is the back-to-school season, Huawei Mate60 series has also launched an autumn promotion: you can enjoy a discount of up to 800 yuan when purchasing the phone, and the starting price is as low as 4,999 yuan. Commonly used and often new products with great value
