我知道,这真的很难过,但我无法连接到MySQL数据库。
我只是简单地从mysql站点下载并解压了mysql-56.6.10-win32.zip。
我紧随其后
this tutorial
,但我无法以root身份连接到我的MySQL数据库。
我知道在没有密码的情况下以root用户身份连接是不安全的,但我只需要做一些测试,所以我现在可以这样做(如果我知道如何以root用户的身份连接,我也知道如何添加另一个用户)。
我的.ini
# 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=c:\Programs\mysql-5.6.10-win32
datadir=c:\Programs\mysql-5.6.10-win32\data
port=3306
server_id=1
# 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
[client]
port=3306
当我开始的时候
mysqld
我懂了:
> mysqld --console --init-file=..\set_root_password.sql
2013-04-02 13:48:24 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-04-02 13:48:24 8600 [Note] Plugin 'FEDERATED' is disabled.
2013-04-02 13:48:24 8600 [Note] InnoDB: The InnoDB memory heap is disabled
2013-04-02 13:48:24 8600 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2013-04-02 13:48:24 8600 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-04-02 13:48:24 8600 [Note] InnoDB: CPU does not support crc32 instructions
2013-04-02 13:48:24 8600 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2013-04-02 13:48:24 8600 [Note] InnoDB: Completed initialization of buffer pool
2013-04-02 13:48:24 8600 [Note] InnoDB: Highest supported file format is Barracuda.
2013-04-02 13:48:24 8600 [Note] InnoDB: 128 rollback segment(s) are active.
2013-04-02 13:48:24 8600 [Note] InnoDB: Waiting for purge to start
2013-04-02 13:48:24 8600 [Note] InnoDB: 1.2.10 started; log sequence number 1626183
2013-04-02 13:48:24 8600 [Note] Server hostname (bind-address): '*'; port: 3306
2013-04-02 13:48:24 8600 [Note] IPv6 is available.
2013-04-02 13:48:24 8600 [Note] - '::' resolves to '::';
2013-04-02 13:48:24 8600 [Note] Server socket created on IP: '::'.
2013-04-02 13:48:24 8600 [Note] Event Scheduler: Loaded 0 events
2013-04-02 13:48:24 8600 [Note] Execution of init_file '..\set_root_password.sql' started.
2013-04-02 13:48:24 8600 [Note] Execution of init_file '..\set_root_password.sql' ended.
2013-04-02 13:48:24 8600 [Note] mysqld: ready for connections.
Version: '5.6.10' socket: '' port: 3306 MySQL Community Server (GPL)
set_root_password.sql
包含我在中找到的一些命令
How to reset root password
,以及我希望他们能帮助的其他人:
UPDATE mysql.user SET Password=PASSWORD('pass') WHERE User='root';
grant all privileges on *.* to 'root'@'%';
grant all privileges on *.* to 'root'@'localhost';
grant all privileges on *.* to 'root@localhost';
SHOW GRANTS FOR 'root'@'%';
FLUSH PRIVILEGES;
但我仍然无法登录。
要登录,我尝试过:
>mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
>mysql -u root --password=pass
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
>mysql
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)
>mysql -u root --password=
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
>mysql -u root --password=mysql
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
>mysql -u root mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
>mysqladmin --no-defaults -u root version
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
在我读到的一些教程中
mysqladmin
命令,但它也需要root密码。
我还尝试了空密码和mysql作为默认密码,但什么都没有。
我也试过了
--skip-grant-tables
没有成功。
我在MySQL主目录的bin目录中没有mysqld_safe,所以我无法尝试。
我试着阅读了这里所有与这个问题有关的问题,但我还不知道我能尝试什么。。。
我很沮丧,为什么它不像“下载并运行”那么简单。我不想下载Win安装程序,因为我不想在Windows启动时启动服务,也不想在没有控制的情况下复制到我的系统中。。。