Chinaunix

标题: mysql装好后,默认应该有个用户的吧? [打印本页]

作者: TOADLover    时间: 2011-03-11 15:19
标题: mysql装好后,默认应该有个用户的吧?
是哪个用户呢?
作者: TOADLover    时间: 2011-03-11 15:20
要不然的话,MySql数据库装好后,岂不是谁都连不上,怎么用啊?
作者: TOADLover    时间: 2011-03-11 15:43
本帖最后由 TOADLover 于 2011-03-11 15:53 编辑

杯具啊。

[root@MySQLServer ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19 to server version: 4.1.22

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show database
    -> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database' at line 1
mysql> show databases;
+----------+
| Database |
+----------+
| abccs    |
| mysql    |
| test     |
+----------+
3 rows in set (0.00 sec)

mysql> grant all on db.* to 'root'@'%' identified by 'root'
    -> ;
Query OK, 0 rows affected (0.11 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[root@MySQLServer ~]# mysql -uroot -proot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@MySQLServer ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 21 to server version: 4.1.22

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> select user();
+----------------+
| user()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

mysql>
作者: TOADLover    时间: 2011-03-11 15:53
本帖最后由 TOADLover 于 2011-03-11 16:13 编辑

用root连Mysql时,不需要指定用户名和密码。。。

mysql> show tables
    -> ;
ERROR 1046 (3D000): No database selected
mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| t              |
| tbl            |
+----------------+
2 rows in set (0.00 sec)

mysql>
作者: beyondfly    时间: 2011-03-11 16:45
在Linux下面,默认用户为root
作者: ruochen    时间: 2011-03-11 19:14
先看看手册吧
作者: tang_123_    时间: 2011-03-12 21:37
root
作者: 909413335    时间: 2011-03-13 00:17
默认用户有好多好多,有3,4个吧。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2