首先启动mysql
服务
[han@localhost
~]$ sudo service mysqld start
启动 MySQL
:
[
确定]
看看mysql
服务有没有起来
[han@localhost
~]$ sudo netstat -tap |grep mysql
tcp
0 0 *:mysql *:*
LISTEN 4386/mysqld
修改root
密码,因为我实在记不得了
[han@localhost
~]$ mysqladmin -u root password root
mysqladmin:
connect to server at 'localhost' failed
error:
'Access denied for user 'root'@'localhost' (using password: NO)'
报错,上网搜索解决方法,如下执行
[han@localhost
~]$ su
密码:
[root@localhost
han]# /etc/init.d/mysqld stop
停止 MySQL
:
[
确定]
[root@localhost
han]# mysqld_safe --user=mysql
--skip-grant-tables --skip-networking &
[1]
4567
[root@localhost
han]# nohup: ignoring input and redirecting stderr to stdout
Starting
mysqld daemon with databases from /var/lib/mysql
mysql
-u root 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.0.67 Source distribution
Type
'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
UPDATE user SET Password=PASSWORD('root') where
USER='root'
->
;
Query
OK, 0 rows affected (0.01 sec)
Rows
matched: 0 Changed: 0 Warnings: 0
mysql>
FLUSH PRIVILEGES;
Query
OK, 0 rows affected (0.00 sec)
mysql>quit
Bye
[root@localhost
han]# service mysqld restart
STOPPING
server from pid file /var/run/mysqld/mysqld.pid
081220
20:37:36 mysqld ended
停止 MySQL
:
[
确定]
启动 MySQL
:
[
确定]
[1]+
Done mysqld_safe --user=mysql --skip-grant-tables
--skip-networking
[root@localhost
han]# mysql -u root -p
Enter
password:
ERROR
1045 (28000): Access denied for user 'root'@'localhost' (using
password: YES)
出错,重试
[root@localhost
han]#mysql -u root -p
Enter
password:
ERROR
1045 (28000): Access denied for user 'root'@'localhost' (using
password: YES)
依然报错,再次上网搜索解决办法,执行如下
[root@localhost
han]# /etc/init.d/mysql stop
bash:
/etc/init.d/mysql:
没有那个文件或目录
拷贝的命令不对,fedora
和ubuntu
的命令不一样,在试
[root@localhost
han]# /etc/init.d/mysqld stop
停止 MySQL
:
[
确定]
[root@localhost
han]# mysqld_safe --user=mysql
--skip-grant-tables --skip-networking &
[1]
4803
[root@localhost
han]# nohup: ignoring input and redirecting stderr to stdout
Starting
mysqld daemon with databases from /var/lib/mysql
mysql
-u root 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.0.67 Source distribution
Type
'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
show databases;
+--------------------+
|
Database |
+--------------------+
|
information_schema |
|
mysql |
|
test |
+--------------------+
3
rows in set (0.00 sec)
mysql>use mysql
Database
changed
mysql>
show tables;
+---------------------------+
|
Tables_in_mysql |
+---------------------------+
|
columns_priv |
|
db |
|
func |
|
help_category |
|
help_keyword |
|
help_relation |
|
help_topic |
|
host |
|
proc |
|
procs_priv |
|
tables_priv |
|
time_zone |
|
time_zone_leap_second |
|
time_zone_name |
|
time_zone_transition |
|
time_zone_transition_type |
|
user |
+---------------------------+
17
rows in set (0.00 sec)
mysql>
UPDATE user SET Password=PASSWORD('root') where
USER='root';
Query
OK, 0 rows affected (0.00 sec)
Rows
matched: 0 Changed: 0 Warnings: 0
mysql>FLUSH PRIVILEGES;
Query
OK, 0 rows affected (0.00 sec)
mysql>quit
Bye
[root@localhost
han]#killall -9 mysqld
/usr/bin/mysqld_safe:
line 388: 4842
已杀死 nohup
/usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql
--user=mysql --pid-file=/var/run/mysqld/mysqld.pid
--skip-external-locking --socket=/var/lib/mysql/mysql.sock
--skip-grant-tables --skip-networking >> /var/log/mysqld.log
2>&1
[root@localhost
han]#
Number
of processes running now: 0
081220
20:43:36 mysqld restarted
[root@localhost
han]# /etc/init.d/mysqld start
启动 MySQL
:
[
确定]
[root@localhost
han]# mysql -u root -p
Enter
password:
终于使用root
密码进来了!
Welcome
to the MySQL monitor.
Commands end with ; or \g.
Your
MySQL connection id is 2
Server
version: 5.0.67 Source distribution
Type
'help;' or '\h' for help. Type '\c' to clear the buffer.
图形工具使用root/root连接
成功登录
分享到:
2008-12-21 13:46
浏览 3491
评论
1 楼
bitray
2011-01-30
fedora下用sudo的不多