使用yum安装mysql服务端:
[root@centos ~]# yum -y install mysql-server
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
epel | 5.3 kB :
extras | 3.3 kB :
os | 3.7 kB :
updates | 3.4 kB :
Resolving Dependencies
--> Running transaction check
---> Package mysql-server.i686 :5.1.-.el6_8 will be installed
--> Processing Dependency: perl-DBI for package: mysql-server-5.1.-.el6_8.i686
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.-.el6_8.i686
--> Processing Dependency: perl(DBI) for package: mysql-server-5.1.-.el6_8.i686
--> Running transaction check
---> Package perl-DBD-MySQL.i686 :4.013-.el6 will be installed
---> Package perl-DBI.i686 :1.609-.el6 will be installed
--> Finished Dependency Resolution Dependencies Resolved =====================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================
Installing:
mysql-server i686 5.1.-.el6_8 os 8.8 M
Installing for dependencies:
perl-DBD-MySQL i686 4.013-.el6 os k
perl-DBI i686 1.609-.el6 os k Transaction Summary
=====================================================================================================================================
Install Package(s) Total download size: 9.6 M
Installed size: M
Downloading Packages:
(/): mysql-server-5.1.-.el6_8.i686.rpm | 8.8 MB :
(/): perl-DBD-MySQL-4.013-.el6.i686.rpm | kB :
(/): perl-DBI-1.609-.el6.i686.rpm | kB :
-------------------------------------------------------------------------------------------------------------------------------------
Total MB/s | 9.6 MB :
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : perl-DBI-1.609-.el6.i686 /
Installing : perl-DBD-MySQL-4.013-.el6.i686 /
Installing : mysql-server-5.1.-.el6_8.i686 /
Verifying : perl-DBD-MySQL-4.013-.el6.i686 /
Verifying : mysql-server-5.1.-.el6_8.i686 /
Verifying : perl-DBI-1.609-.el6.i686 / Installed:
mysql-server.i686 :5.1.-.el6_8 Dependency Installed:
perl-DBD-MySQL.i686 :4.013-.el6 perl-DBI.i686 :1.609-.el6 Complete!
执行启动报错:
[root@centos ~]# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
:: [ERROR] Can't find messagefile '/usr/share/mysql/english/errmsg.sys'
:: [ERROR] Aborting :: [Note] Installation of system tables failed! Examine the logs in
/var/lib/mysql for more information. You can try to start the mysqld daemon with: shell> /usr/libexec/mysqld --skip-grant & and use the command line tool /usr/bin/mysql
to connect to the mysql database and look at the grant tables: shell> /usr/bin/mysql -u root mysql
mysql> show tables Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /var/lib/mysql that may be helpful. Please consult the MySQL manual section
'Problems running mysql_install_db', and the manual section that
describes problems on your OS. Another information source are the
MySQL email archives available at http://lists.mysql.com/. Please check all of the above before mailing us! And remember, if
you do mail us, you MUST use the /usr/bin/mysqlbug script! [FAILED]
[root@centos mysql]# yum remove mysql
Loaded plugins: fastestmirror, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package mysql.i686 :5.1.-.el6_8 will be erased
--> Processing Dependency: mysql = 5.1.-.el6_8 for package: mysql-server-5.1.-.el6_8.i686
--> Running transaction check
---> Package mysql-server.i686 :5.1.-.el6_8 will be erased
--> Finished Dependency Resolution Dependencies Resolved =======================================================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================================================
Removing:
mysql i686 5.1.-.el6_8 @os 2.3 M
Removing for dependencies:
mysql-server i686 5.1.-.el6_8 @os M Transaction Summary
=======================================================================================================================================================================
Remove Package(s) Installed size: M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : mysql-server-5.1.-.el6_8.i686 /
Erasing : mysql-5.1.-.el6_8.i686 /
warning: erase unlink of /usr/lib/mysql/mysqlbug failed: No such file or directory
warning: erase unlink of /usr/lib/mysql/mysql_config failed: No such file or directory
warning: erase unlink of /usr/bin/mysql failed: No such file or directory
Verifying : mysql-server-5.1.-.el6_8.i686 /
Verifying : mysql-5.1.-.el6_8.i686 / Removed:
mysql.i686 :5.1.-.el6_8 Dependency Removed:
mysql-server.i686 :5.1.-.el6_8 Complete!
继续看看哪儿还有mysql文件并删除:
[root@centos ~]# whereis mysql
mysql: /usr/lib/mysql /usr/share/mysql
[root@centos ~]# rm -rf /usr/lib/mysql /usr/share/mysql
重新安装mysql-server和启动命令,又抛出另一个异常:
[root@centos ~]# service mysqld start
/usr/bin/mysqladmin: error while loading shared libraries: libmysqlclient.so.: cannot open shared object file: No such file or directory
Cannot check for MySQL Daemon startup because of mysqladmin failure.
Starting mysqld: [FAILED]
看来不行,再来一次彻底的删除,不要留任何卸载残留,斩尽杀绝:
[root@centos ~]# find / -name mysql
/usr/share/mysql
/usr/lib/perl5/auto/DBD/mysql
/usr/lib/perl5/DBD/mysql
/usr/lib/mysql
/var/lib/mysql
/var/lib/mysql/mysql
[root@centos ~]# rm -rf /usr/share/mysql /usr/lib/perl5/auto/DBD/mysql /usr/lib/perl5/DBD/mysql /usr/lib/mysql /var/lib/mysql
[root@centos ~]# find / -name mysql
[root@centos ~]# yum remove mysql mysql-server mysql-libs
Loaded plugins: fastestmirror, security
Setting up Remove Process
No Match for argument: mysql
Loading mirror speeds from cached hostfile
Package(s) mysql available, but not installed.
No Match for argument: mysql-server
Package(s) mysql-server available, but not installed.
Resolving Dependencies
--> Running transaction check
---> Package mysql-libs.i686 :5.1.-.el6_8 will be erased
--> Processing Dependency: libmysqlclient.so. for package: :postfix-2.6.-.el6.i686
--> Processing Dependency: libmysqlclient.so. for package: perl-DBD-MySQL-4.013-.el6.i686
--> Processing Dependency: libmysqlclient.so.(libmysqlclient_16) for package: :postfix-2.6.-.el6.i686
--> Processing Dependency: libmysqlclient.so.(libmysqlclient_16) for package: perl-DBD-MySQL-4.013-.el6.i686
--> Processing Dependency: mysql-libs for package: :postfix-2.6.-.el6.i686
--> Running transaction check
---> Package perl-DBD-MySQL.i686 :4.013-.el6 will be erased
---> Package postfix.i686 :2.6.-.el6 will be erased
--> Processing Dependency: /usr/sbin/sendmail for package: cronie-1.4.-.el6_8..i686
--> Running transaction check
---> Package cronie.i686 :1.4.-.el6_8. will be erased
--> Processing Dependency: cronie = 1.4.-.el6_8. for package: cronie-anacron-1.4.-.el6_8..i686
--> Running transaction check
---> Package cronie-anacron.i686 :1.4.-.el6_8. will be erased
--> Processing Dependency: /etc/cron.d for package: crontabs-1.10-.el6.noarch
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package crontabs.noarch :1.10-.el6 will be erased
--> Finished Dependency Resolution Dependencies Resolved =======================================================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================================================
Removing:
mysql-libs i686 5.1.-.el6_8 @anaconda-CentOS-.i386/6.9 3.9 M
Removing for dependencies:
cronie i686 1.4.-.el6_8. @anaconda-CentOS-.i386/6.9 k
cronie-anacron i686 1.4.-.el6_8. @anaconda-CentOS-.i386/6.9 k
crontabs noarch 1.10-.el6 @anaconda-CentOS-.i386/6.9 2.4 k
perl-DBD-MySQL i686 4.013-.el6 @os k
postfix i686 :2.6.-.el6 @anaconda-CentOS-.i386/6.9 9.4 M Transaction Summary
=======================================================================================================================================================================
Remove Package(s) Installed size: M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : cronie-anacron-1.4.-.el6_8..i686 /
Erasing : crontabs-1.10-.el6.noarch /
Erasing : cronie-1.4.-.el6_8..i686 /
Erasing : :postfix-2.6.-.el6.i686 /
Erasing : perl-DBD-MySQL-4.013-.el6.i686 /
warning: erase unlink of /usr/lib/perl5/auto/DBD/mysql/mysql.so failed: No such file or directory
warning: erase unlink of /usr/lib/perl5/auto/DBD/mysql failed: No such file or directory
warning: erase unlink of /usr/lib/perl5/DBD/mysql/INSTALL.pod failed: No such file or directory
warning: erase unlink of /usr/lib/perl5/DBD/mysql/GetInfo.pm failed: No such file or directory
warning: erase unlink of /usr/lib/perl5/DBD/mysql failed: No such file or directory
Erasing : mysql-libs-5.1.-.el6_8.i686 /
warning: erase unlink of /usr/share/mysql/ukrainian/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/ukrainian failed: No such file or directory
warning: erase unlink of /usr/share/mysql/swedish/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/swedish failed: No such file or directory
warning: erase unlink of /usr/share/mysql/spanish/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/spanish failed: No such file or directory
warning: erase unlink of /usr/share/mysql/slovak/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/slovak failed: No such file or directory
warning: erase unlink of /usr/share/mysql/serbian/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/serbian failed: No such file or directory
warning: erase unlink of /usr/share/mysql/russian/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/russian failed: No such file or directory
warning: erase unlink of /usr/share/mysql/romanian/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/romanian failed: No such file or directory
warning: erase unlink of /usr/share/mysql/portuguese/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/portuguese failed: No such file or directory
warning: erase unlink of /usr/share/mysql/polish/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/polish failed: No such file or directory
warning: erase unlink of /usr/share/mysql/norwegian/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/norwegian-ny/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/norwegian-ny failed: No such file or directory
warning: erase unlink of /usr/share/mysql/norwegian failed: No such file or directory
warning: erase unlink of /usr/share/mysql/korean/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/korean failed: No such file or directory
warning: erase unlink of /usr/share/mysql/japanese/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/japanese failed: No such file or directory
warning: erase unlink of /usr/share/mysql/italian/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/italian failed: No such file or directory
warning: erase unlink of /usr/share/mysql/hungarian/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/hungarian failed: No such file or directory
warning: erase unlink of /usr/share/mysql/greek/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/greek failed: No such file or directory
warning: erase unlink of /usr/share/mysql/german/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/german failed: No such file or directory
warning: erase unlink of /usr/share/mysql/french/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/french failed: No such file or directory
warning: erase unlink of /usr/share/mysql/estonian/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/estonian failed: No such file or directory
warning: erase unlink of /usr/share/mysql/english/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/english failed: No such file or directory
warning: erase unlink of /usr/share/mysql/dutch/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/dutch failed: No such file or directory
warning: erase unlink of /usr/share/mysql/danish/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/danish failed: No such file or directory
warning: erase unlink of /usr/share/mysql/czech/errmsg.sys failed: No such file or directory
warning: erase unlink of /usr/share/mysql/czech failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/swe7.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/macroman.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/macce.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/latin7.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/latin5.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/latin2.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/latin1.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/koi8u.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/koi8r.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/keybcs2.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/hp8.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/hebrew.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/greek.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/geostd8.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/dec8.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/cp866.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/cp852.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/cp850.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/cp1257.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/cp1256.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/cp1251.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/cp1250.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/ascii.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/armscii8.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/README failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets/Index.xml failed: No such file or directory
warning: erase unlink of /usr/share/mysql/charsets failed: No such file or directory
warning: erase unlink of /usr/share/mysql failed: No such file or directory
warning: erase unlink of /usr/lib/mysql/libmysqlclient_r.so.16.0. failed: No such file or directory
warning: erase unlink of /usr/lib/mysql/libmysqlclient_r.so. failed: No such file or directory
warning: erase unlink of /usr/lib/mysql/libmysqlclient.so.16.0. failed: No such file or directory
warning: erase unlink of /usr/lib/mysql/libmysqlclient.so. failed: No such file or directory
warning: erase unlink of /usr/lib/mysql failed: No such file or directory
Verifying : perl-DBD-MySQL-4.013-.el6.i686 /
Verifying : crontabs-1.10-.el6.noarch /
Verifying : mysql-libs-5.1.-.el6_8.i686 /
Verifying : cronie-1.4.-.el6_8..i686 /
Verifying : cronie-anacron-1.4.-.el6_8..i686 /
Verifying : :postfix-2.6.-.el6.i686 / Removed:
mysql-libs.i686 :5.1.-.el6_8 Dependency Removed:
cronie.i686 :1.4.-.el6_8. cronie-anacron.i686 :1.4.-.el6_8. crontabs.noarch :1.10-.el6 perl-DBD-MySQL.i686 :4.013-.el6 postfix.i686 :2.6.-.el6 Complete!
[root@centos ~]# rpm -qa | grep mysql
我们通过yum remove mysql mysql-server mysql-libs命令删掉了mysql相关的所有东西,再通过find / -name mysql和rpm -qa | grep mysql来确认斩草除根。
最后重新安装一次mysql-server再启动,这次启动成功了:
[root@centos ~]# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
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 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 centos password 'new-password' 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 & 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 ]