iT邦幫忙

0

myqsql 登入問題

s00692 2011-10-18 12:16:0131608 瀏覽

小弟是新手
系統:centos6.0
mysqlversion:5.1.52-1.el6_0.1.x86_64
在登入mysql時(mysql -u root)出現
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)無法登入
試過教學

/etc/init.d/mysqld stop

mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

mysql -u root mysql

mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit

/etc/init.d/mysqld restart

#mysql -u root -p
還是不行
請各位幫幫忙
謝謝

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

4
隨風奶爸
iT邦好手 1 級 ‧ 2011-10-19 09:09:27
最佳解答

修改 /etc/my.cnf ,
在 [mysqld]下面 加入下面的一行

skip-grant-tables

存檔後重啟mysqld 服務。
接著,你可以使用任何用戶名以root管理員的身份登錄 MySQL 了。

進入mysql後,修改mysql DB中的user表格
use mysql;
update user set password=PASSword('你要的密碼') where user='root';
flush privileges;

退出MYSQL管理

刪除上面在/etc/my.cnf 所添加的內容,重啟服務。

s00692 iT邦新手 5 級 ‧ 2011-10-19 14:36:20 檢舉

追加一問MYSQL -u root -p 可以登入,但是phpmyadmin出現You don't have permission to access /phpMyAdmin on this server.這個問題.
設定如下:
把phpmyadmin放到/var/www/html
cp config.default.php /var/www/html/phpmyadmin/config.inc.php
修改config.inc.php
$cfg['Servers'][$i]['controluser'] = 'root';
$cfg['Servers'][$i]['controlpass'] = '你的mysql密碼';
$cfg['Servers'][$i]['auth_type'] = 'http';
請大大再次幫幫忙

4
pkjammy
iT邦新手 5 級 ‧ 2011-10-19 10:51:23

MySql比較嚴謹一點,除了本機以外,可以指定某機器並使用某帳號才可以連接

語法格式:grant 權限 on 數據庫名.表名 用戶@登錄主機 identified by "用戶密碼"
以下語法是任何機器都可以使用 ‘MySQL帳號’ 連線:
GRANT ALL PRIVILEGES ON *.* TO ‘MySQL帳號’@'%’ IDENTIFIED BY ‘MySQL密碼’ WITH GRANT OPTION;

我要發表回答

立即登入回答