mysql登陸報錯:ERROR 1045 (28000): Access denied for user root@localhost (using password: NO)

網上一大堆解決方法,這裏只是補充。mysql

網友給出的安全模式跳過權限表的解決方法:sql

# /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: <輸入新設的密碼newpassword>
mysql> 安全

按照上述操做,出現如下問題:ui

1、執行 mysqld_safe 時,報錯/usr/local/mysql/bin/mysqlld 找不到;rest

      解決:將mysql的安裝路徑/mysql/bin下的mysqld連接至/usr/local/mysql/bin/mysqlld日誌

                #ln -s /server/mysql-5.5.37/bin/mysqld   /usr/local/mysql/bin/mysqldserver

2、再次執行mysqld_safe發現mysql服務並無啓動起來;ip

       解決:查看日誌,發現【error】說是路徑的問題;在mysql配置文件my.conf中添加:it

                basedir=/server/mysql              mysql路徑
                datadir=/server/mysql/data      mysql data路徑table

相關文章
相關標籤/搜索