如何在MySQL中创建用户并登录

时间:2015-05-24 18:14:54

标签: mysql

我是MySQL的新手,我正在尝试安装它并设置MySQL,这样我就可以在学校进行独立学习练习和学习。我正在关注此视频" https://www.youtube.com/watch?v=O4xXzTIcnDE"关于如何安装MySQL。如果有人知道要安装MySQL的更好的视频,请链接它。我使用的是Windows 7三星笔记本电脑64位。

我被困在用户和密码部分。我按照视频尝试创建用户和密码但是当我尝试使用" C:\ mysql \ bin> mysql -u root -p"。

时出现错误

以下是cmd的确切代码。查看错误的最后2行。我用这行来创建一个用户并给它一个密码:" mysql>更新mysql.user set password = password(' password')其中user =' root';"

我将password =设置为密码,因此很容易记住。

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>mysqld --install
Service successfully installed.

C:\Windows\system32>mysql -u root
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

C:\Windows\system32>sc delete MySQL
[SC] DeleteService SUCCESS

C:\Windows\system32>cd\mysql\bin

C:\mysql\bin>mysqld --install
The service already exists!
The current server installed: "C:\Program Files\MySQL\MySQL Server 5.6\mysqld" MySQL

C:\mysql\bin>mysqld --remove
The service doesn't exist!

C:\mysql\bin>mysqld --install
Service successfully installed.

C:\mysql\bin>mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql;
Database changed
mysql> update mysql.user set password = password('password') where user = 'root'
-> update mysql.user set password = password('password') where user = 'root';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corre
sponds to your MySQL server version for the right syntax to use near 'update mysql.us
er set password = password('password') where user = 'root'' at line 2
mysql>
mysql> update mysql.user set password = password('password') where user = 'root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql> select user, host from user;
+------+-----------+
| user | host      |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1       |
|      | localhost |
| root | localhost |
+------+-----------+
4 rows in set (0.00 sec)

mysql> select user, host from user where user = '';
+------+-----------+
| user | host      |
+------+-----------+
|      | localhost |
+------+-----------+
1 row in set (0.00 sec)

mysql> delete from user where user = '';
Query OK, 1 row affected (0.00 sec)

mysql> quit
Bye

C:\mysql\bin>mysql -u root -p
Enter password: ********
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

C:\mysql\bin>mysql -u root -p
Enter password: ********
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

C:\mysql\bin>

1 个答案:

答案 0 :(得分:-1)

尝试谷歌它!

How to setup mysql database

我喜欢这个教程。试试本教程 Step by Step

Installing mysql step by step

<强>编辑: 使用此命令以admin:

登录
C:\MYSQL\Bin>mysql -u root -p admin

链接: How to connect from windows command prompt to mysql command line