装完ubuntu server-11.04忘记刚刚设计的密码,于是就在网上找了解决方案。
以下为操作全过程
sudo /etc/init.d/mysql stop
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql stop
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) utility, e.g. stop mysql
mysql stop/waiting
sudo mysqld_safe --skip-grant-tables &
[1] 10528
cy@ubuntu://$ 110617 17:43:59 mysqld_safe Logging to syslog.
110617 17:43:59 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
mysql mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.54-1ubuntu4 (Ubuntu)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
update user set password=password('111111') where user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql>
flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
quit
Bye
sudo killall mysqld
cy@ubuntu://$ 110617 17:45:35 mysqld_safe mysqld from pid file /var/lib/mysql/ubuntu.pid ended
[1]+ 完成 sudo mysqld_safe --skip-grant-tables
sudo /etc/init.d/mysql start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql start
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start mysql
mysql start/running, process 10681
mysql -uroot -p111111
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 43
Server version: 5.1.54-1ubuntu4 (Ubuntu)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>