Mysql修改密碼,遠端登入,ERROR 1044 (42000)錯誤解決辦法
[[email protected] ~]# mysql -u root
第二步:改變使用者資料庫
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
第三步:修改密碼,記得密碼要用password()函式進行加密,一定不要忘記!!!
mysql> update user set password=password('qwe123') where user='root';
Query OK, 1 row affected (0.04 sec)
Rows matched: 1 Changed: 1 Warnings: 0
第四步:重新整理許可權表
mysql> flush previleges;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘previleges’ at line 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
第五步:退出mysql
mysql> quit
Bye
第六步:對mysql進行重啟
[
STOPPING server from pid file /var/run/mysqld/mysqld.pid
100421 13:44:03 mysqld ended
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
[1]+ Done mysqld_safe –skip-grant-tables
mysql資料庫遠端連線開啟方法
登陸MYSQL mysql -u root -p 進入mysql庫mysql> use mysql; 查詢user表下的幾個欄位的內容 mysql>select host,user,password from user; MySQL>select host, user from user; mysql>update user set host = '%' where user = 'root'; MySQL>update user set host = '%' where user = 'root'; mysql>
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
方法一:1.關閉mysql
# service mysqld stop
2.遮蔽許可權
# mysqld_safe --skip-grant-table
螢幕出現: Starting demo from .....
3.新開起一個終端輸入
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;//記得要這句話,否則如果關閉先前的終端,又會出現原來的錯誤
mysql> \q
方法二:
1.關閉mysql
# service mysqld stop
2.遮蔽許可權
# mysqld_safe --skip-grant-table
螢幕出現: Starting demo from .....
3.新開起一個終端輸入
# mysql -u root mysql
mysql> delete from user where USER='';
mysql> FLUSH PRIVILEGES;//記得要這句話,否則如果關閉先前的終端,又會出現原來的錯誤
mysql> \q
本文轉載自:http://cx7863.blog.163.com/blog/#m=0&t=3&c=mysql 不過本人mysql資料庫遠端連線開啟方法用的是: 允許任何主機使用“myuser”賬號和“mypwd”密碼連線到 MySQL 伺服器。
mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypwd' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
允許使用者myuser從ip為192.168.1.3的主機連線到mysql伺服器,並使用mypwd作為密碼
mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypwd' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;