背景:用yum安装的mysql5.1数据库,然后删除了mysql库中user表中的localhost和127.0.0.1用户,数据库无法登陆。

操作步骤:#rpm -qa | grep mysql
        #yum remove -y mysql*
        #yum install -y mysql*
        #service mysqld start  //屏幕出现的结果是cmake编译安装的最后一步,对mysql进行初始化,在此命令执行之前,/var/lib/mysql(数据文件目录是空的)。重新进行编译安装后到数据库中查看,是一个新库。如果是生产环节,需要对之前的备份进行恢复。
----------------------------------------------------------
[root@xin mysql]# service mysqld start
Initializing MySQL database:  Installing MySQL system tables...
OK  初始化MYSQL数据库,安装MYSQL数据库系统表。
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
mysqld文件是复制mysql.server

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h xin.mysql password 'new-password'
root用户本地和远程创建密码

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &   也是一种MYSQL启动方式

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl //执行该脚本,能看见很多主从进程直接的关系

Please report any problems with the /usr/bin/mysqlbug script! //该脚本如何用

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
[root@xin mysql]#