在mysql创建数据表不成功为什么
答案:2 悬赏:60
解决时间 2021-03-23 02:03
- 提问者网友:✐ۖ﹏ℳ๓北风
- 2021-03-22 03:03
在mysql创建数据表不成功为什么
最佳答案
- 二级知识专家网友:零负荷的放任
- 2021-03-22 04:19
第一种情况是:
root:/#mysql -u -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15 to server version: 5.0.91-enterprise-gpl
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+
2 rows in set (1.05 sec)
mysql>
mysql>
mysql>
mysql> create database company
-> ;
ERROR 1044: Access denied for user ''@'localhost' to database 'company'
mysql>
第二种情况是:
root:/#mysql -u root -p
Enter password: (我输入了密码)
ERROR 1045: Access denied for user 'root'@'localhost' (using password: YES)
root:/#
only13loving
采纳率:51%12级2013.09.22
试这两个
mysql -h 127.0.0.1 -u root -p
mysql -h servername -u root -p
root:/#mysql -u -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15 to server version: 5.0.91-enterprise-gpl
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+
2 rows in set (1.05 sec)
mysql>
mysql>
mysql>
mysql> create database company
-> ;
ERROR 1044: Access denied for user ''@'localhost' to database 'company'
mysql>
第二种情况是:
root:/#mysql -u root -p
Enter password: (我输入了密码)
ERROR 1045: Access denied for user 'root'@'localhost' (using password: YES)
root:/#
only13loving
采纳率:51%12级2013.09.22
试这两个
mysql -h 127.0.0.1 -u root -p
mysql -h servername -u root -p
全部回答
- 1楼网友:猖狂的痴情人
- 2021-03-22 05:56
有两种方法,一种方法使用mysql的check table和repair table 的sql语句,另一种方法是使用mysql提供的多个myisamchk, isamchk数据检测恢复工具。前者使用起来比较简便。推荐使用。
1. check table 和 repair table
登陆mysql 终端:
mysql -uxxxxx -p dbname
check table tabtest;
如果出现的结果说status是ok,则不用修复,如果有error,可以用:
repair table tabtest;
进行修复,修复之后可以在用check table命令来进行检查。在新版本的phpmyadmin里面也可以使用check/repair的功能。
2. myisamchk, isamchk
其中myisamchk适用于myisam类型的数据表,而isamchk适用于isam类型的数据表。这两条命令的主要参数相同,一般新的系统都使用myisam作为缺省的数据表类型,这里以myisamchk为例子进行说明。当发现某个数据表出现问题时可以使用:
myisamchk tablename.myi
进行检测,如果需要修复的话,可以使用:
myisamchk -of tablename.myi
关于myisamchk的详细参数说明,可以参见它的使用帮助。需要注意的时在进行修改时必须确保mysql服务器没有访问这个数据表,保险的情况下是最好在进行检测时把mysql服务器shutdown掉。
-----------------------------
另外可以把下面的命令放在你的rc.local里面启动mysql服务器前:
[ -x /tmp/mysql.sock ] && /pathtochk/myisamchk -of /data_dir/*/*.myi
其中的/tmp/mysql.sock是mysql监听的sock文件位置,对于使用rpm安装的用户应该是/var/lib/mysql/mysql.sock,对于使用源码安装则是/tmp/mysql.sock可以根据自己的实际情况进行变更,而pathtochk则是myisamchk所在的位置,data_dir是你的mysql数据库存放的位置。
需要注意的时,如果你打算把这条命令放在你的rc.local里面,必须确认在执行这条指令时mysql服务器必须没有启动!检测修复所有数据库(表)
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯