在RedHat5.5上用rpm安裝MySQL 5.6裝好mysql之後 見
用mysqladmin修改密碼(mysqladmin –u root password “mysql”)提示
mysqladmin:Can't turn off logging; error: 'Access denied; you need the SUPER privilege forthis operation'
解決辦法:
修改mysql登入設定
vi /etc/my.cnf (我們發現etc下沒有my.cnf檔案)
通過查詢知道,安裝完MySQL 後,/etc/my.cnf 檔案預設是不存在的,可以在/usr/share/doc/MySQL-servercommunity下找到my-huge.cnf 、my-innodb-heavy-4G.cnf 、my-large.cnf 、mymedium.cnf 、my-small.cnf 等檔案,根據記憶體大小將其中合適你機器配置的檔案拷貝到/etc/my.cnf(一般應用選mymedium.cnf即可)
編輯my.cnf檔案
在[mysqld]段中加入 skip-grant-tables
儲存之後重啟mysql服務
/etc/rc.d/init.d/mysql restart
重啟mysql服務之後修改mysql密碼
[root@shiyue]# mysql
Welcome to the MySQL monitor. Commands endwith ; or \g.
Your MySQL connection id is 3 to server version: 3.23.56
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> UPDATE user SET Password = password ( 'mysql' ) WHERE User = 'root' ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
退出mysql之後把剛修改的設定檔改回來(vi /etc/my.cnf)
重啟mysql服務
mysql-u root -p登入mysql
登陸成功!
再通過navicat串連mysql資料庫,提示Can't get hostname for your address
解決方案還是修改my.cnf檔案,在[mysqld] 下面添加一行:skip-name-resolve,儲存重啟mysql(/etc/init.d/mysql restart)
賦權:
Mysql –u root –p mysql
Show databases
Use mysql
grant all on *.* to 'root'@'192.168.1.254'identified by 'mysql';
quit
好重新用navicat進行串連,OK,測試通過!