隨筆-95  評論-31  文章-10  trackbacks-0
          問題:
          [root@localhost mysql]# mysql -u root -p
          Enter password:
          ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
          解決方法:
          方法一:
          # /etc/init.d/mysql 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/mysql restart
          # mysql -uroot -p
          Enter password: <輸入新設(shè)的密碼newpassword>
          mysql>
          方法二:
          直接使用/etc/mysql/debian.cnf文件中[client]節(jié)提供的用戶名和密碼:
          # mysql -udebian-sys-maint -p
          Enter password: <輸入[client]節(jié)的密碼>
          mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;
          mysql> FLUSH PRIVILEGES;
          mysql> quit
          # mysql -uroot -p
          Enter password: <輸入新設(shè)的密碼newpassword>
          mysql>

          上面方法執(zhí)行完畢后,登錄mysql還需要設(shè)置密碼,否則無法進行其他操作,提示需設(shè)置密碼
          set password=password('weixiao');

          mysql安裝好以后在linux下的目錄
                1、數(shù)據(jù)庫目錄
            /var/lib/mysql/

            2、配置文件
            /usr/share/mysql(mysql.server命令及配置文件)

            3、相關(guān)命令
            /usr/bin(mysqladmin mysqldump等命令)

            4、啟動腳本
            /etc/init.d/mysql   start|stop|restart|status(啟動腳本文件mysql的目錄)


          linux安裝好服務(wù)后,開放端口命令:

          /sbin/iptables -I INPUT -p tcp --dport 9090 -j ACCEPT; (區(qū)分大小寫)

          然后輸入以下命令查看端口:

          /etc/init.d/iptables status

          最后還需要保存并重啟防火墻

          /etc/rc.d/init.d/iptables save (保存)

          service iptables restart (重啟)

          一切ok,可以遠(yuǎn)程訪問了

          ********************************************************

          當(dāng)用mysql工具遠(yuǎn)程訪問的時候會報這個錯:

          Host  is not allowed to connect to this MySQL server

          這是因為沒有授權(quán),如果你想從任何主機連接到mysql服務(wù)器的話。

          grant all privileges on *.* to 'root'@'%' identified by 'weixiao' with grant option;

          如果你想只允許用戶從固定ip的主機連接到mysql服務(wù)器的話。

          grant all privileges on *.* to 'root'@'170.12.12.155' identified by 'weixiao' with grant option;

          posted on 2013-07-18 13:26 朔望魔刃 閱讀(17855) 評論(1)  編輯  收藏 所屬分類: 各種配置

          評論:
          # re: linux安裝mysql后root無法登錄 2015-08-26 21:44 | galo
          謝啦  回復(fù)  更多評論
            
          主站蜘蛛池模板: 五家渠市| 松溪县| 扶风县| 桐城市| 车险| 辽宁省| 宣武区| 抚松县| 松阳县| 来宾市| 惠安县| 壤塘县| 祥云县| 延吉市| 辉县市| 遂川县| 闽侯县| 正阳县| 铜山县| 商都县| 常熟市| 堆龙德庆县| 商丘市| 界首市| 宣武区| 宜章县| 浦江县| 阿克| 武穴市| 台南市| 广东省| 麻栗坡县| 台北市| 化州市| 武城县| 庆安县| 林芝县| 东辽县| 平舆县| 隆安县| 勐海县|