MySQL|linux下mysql的卸载、安装全过程

卸载mysql
1、查找以前是否装有mysql
命令:rpm -qa|grep -i mysql
可以看到mysql的包:

mysql-libs-5.1.71-1.el6.x86_64

2、删除mysql
删除命令:rpm -e mysql-libs-5.1.71-1.el6.x86_64 --nodeps
卸载完成
安装mysql
【MySQL|linux下mysql的卸载、安装全过程】自动下载安装
yum install mysql-server mysql mysql-devel
[hadoop@note1 ~]$ sudo yum install mysql-server mysql mysql-devel Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.neusoft.edu.cn Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package mysql.x86_64 0:5.1.73-7.el6 will be installed --> Processing Dependency: mysql-libs = 5.1.73-7.el6 for package: mysql-5.1.73-7.el6.x86_64 --> Processing Dependency: libmysqlclient_r.so.16(libmysqlclient_16)(64bit) for package: mysql-5.1.73-7.el6.x86_64 --> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: mysql-5.1.73-7.el6.x86_64 --> Processing Dependency: libmysqlclient_r.so.16()(64bit) for package: mysql-5.1.73-7.el6.x86_64 --> Processing Dependency: libmysqlclient.so.16()(64bit) for package: mysql-5.1.73-7.el6.x86_64 ---> Package mysql-devel.x86_64 0:5.1.73-7.el6 will be installed --> Processing Dependency: openssl-devel for package: mysql-devel-5.1.73-7.el6.x86_64 ---> Package mysql-server.x86_64 0:5.1.73-7.el6 will be installed --> Processing Dependency: perl-DBI for package: mysql-server-5.1.73-7.el6.x86_64 --> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.73-7.el6.x86_64 --> Processing Dependency: perl(DBI) for package: mysql-server-5.1.73-7.el6.x86_64 --> Running transaction check ---> Package mysql-libs.x86_64 0:5.1.73-7.el6 will be installed ---> Package openssl-devel.x86_64 0:1.0.1e-48.el6_8.3 will be installed --> Processing Dependency: openssl = 1.0.1e-48.el6_8.3 for package: openssl-devel-1.0.1e-48.el6_8.3.x86_64 --> Processing Dependency: zlib-devel for package: openssl-devel-1.0.1e-48.el6_8.3.x86_64 --> Processing Dependency: krb5-devel for package: openssl-devel-1.0.1e-48.el6_8.3.x86_64 ---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed ---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed --> Running transaction check ---> Package krb5-devel.x86_64 0:1.10.3-57.el6 will be installed --> Processing Dependency: krb5-libs = 1.10.3-57.el6 for package: krb5-devel-1.10.3-57.el6.x86_64 --> Processing Dependency: libselinux-devel for package: krb5-devel-1.10.3-57.el6.x86_64 --> Processing Dependency: libcom_err-devel for package: krb5-devel-1.10.3-57.el6.x86_64 --> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.10.3-57.el6.x86_64 ---> Package openssl.x86_64 0:1.0.1e-15.el6 will be updated ---> Package openssl.x86_64 0:1.0.1e-48.el6_8.3 will be an update ---> Package zlib-devel.x86_64 0:1.2.3-29.el6 will be installed --> Running transaction check ---> Package keyutils-libs-devel.x86_64 0:1.4-5.el6 will be installed --> Processing Dependency: keyutils-libs = 1.4-5.el6 for package: keyutils-libs-devel-1.4-5.el6.x86_64 ---> Package krb5-libs.x86_64 0:1.10.3-10.el6_4.6 will be updated --> Processing Dependency: krb5-libs = 1.10.3-10.el6_4.6 for package: krb5-workstation-1.10.3-10.el6_4.6.x86_64 ---> Package krb5-libs.x86_64 0:1.10.3-57.el6 will be an update ---> Package libcom_err-devel.x86_64 0:1.41.12-22.el6 will be installed --> Processing Dependency: libcom_err = 1.41.12-22.el6 for package: libcom_err-devel-1.41.12-22.el6.x86_64 ---> Package libselinux-devel.x86_64 0:2.0.94-7.el6 will be installed --> Processing Dependency: libselinux = 2.0.94-7.el6 for package: libselinux-devel-2.0.94-7.el6.x86_64 --> Processing Dependency: libsepol-devel >= 2.0.32-1 for package: libselinux-devel-2.0.94-7.el6.x86_64 --> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.0.94-7.el6.x86_64 --> Running transaction check ---> Package keyutils-libs.x86_64 0:1.4-4.el6 will be updated --> Processing Dependency: keyutils-libs = 1.4-4.el6 for package: keyutils-1.4-4.el6.x86_64 ---> Package keyutils-libs.x86_64 0:1.4-5.el6 will be an update ---> Package krb5-workstation.x86_64 0:1.10.3-10.el6_4.6 will be updated ---> Package krb5-workstation.x86_64 0:1.10.3-57.el6 will be an update ---> Package libcom_err.x86_64 0:1.41.12-18.el6 will be updated --> Processing Dependency: libcom_err = 1.41.12-18.el6 for package: e2fsprogs-libs-1.41.12-18.el6.x86_64 --> Processing Dependency: libcom_err = 1.41.12-18.el6 for package: libss-1.41.12-18.el6.x86_64 --> Processing Dependency: libcom_err = 1.41.12-18.el6 for package: e2fsprogs-1.41.12-18.el6.x86_64 ---> Package libcom_err.x86_64 0:1.41.12-22.el6 will be an update ---> Package libselinux.x86_64 0:2.0.94-5.3.el6_4.1 will be updated --> Processing Dependency: libselinux = 2.0.94-5.3.el6_4.1 for package: libselinux-python-2.0.94-5.3.el6_4.1.x86_64 --> Processing Dependency: libselinux = 2.0.94-5.3.el6_4.1 for package: libselinux-utils-2.0.94-5.3.el6_4.1.x86_64 ---> Package libselinux.x86_64 0:2.0.94-7.el6 will be an update ---> Package libsepol-devel.x86_64 0:2.0.41-4.el6 will be installed --> Running transaction check ---> Package e2fsprogs.x86_64 0:1.41.12-18.el6 will be updated ---> Package e2fsprogs.x86_64 0:1.41.12-22.el6 will be an update ---> Package e2fsprogs-libs.x86_64 0:1.41.12-18.el6 will be updated ---> Package e2fsprogs-libs.x86_64 0:1.41.12-22.el6 will be an update ---> Package keyutils.x86_64 0:1.4-4.el6 will be updated ---> Package keyutils.x86_64 0:1.4-5.el6 will be an update ---> Package libselinux-python.x86_64 0:2.0.94-5.3.el6_4.1 will be updated ---> Package libselinux-python.x86_64 0:2.0.94-7.el6 will be an update ---> Package libselinux-utils.x86_64 0:2.0.94-5.3.el6_4.1 will be updated ---> Package libselinux-utils.x86_64 0:2.0.94-7.el6 will be an update ---> Package libss.x86_64 0:1.41.12-18.el6 will be updated ---> Package libss.x86_64 0:1.41.12-22.el6 will be an update --> Finished Dependency ResolutionDependencies Resolved==============================================================================================================

直到complete
切换到root权限
service mysqld start

或者sudo操作下
[hadoop@note1 ~]$ sudo service mysqld start Initializing MySQL database:Installing MySQL system tables... OK Filling help tables... OKTo start mysqld at boot time you have to copy support-files/mysql.server to the right place for your systemPLEASE 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 note1 password 'new-password'Alternatively you can run: /usr/bin/mysql_secure_installationwhich 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.plPlease report any problems with the /usr/bin/mysqlbug script! [OK]**对MySQL进行安装**

/usr/bin/mysql_secure_installation
[hadoop@note1 ~]$ /usr/bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we’ll need the current
password for the root user. If you’ve just installed MySQL, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on…
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
… Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
… Success!
Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n
… skipping.
By default, MySQL comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
- Dropping test database…
… Success!
- Removing privileges on test database…
… Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
… Success!
Cleaning up…
All done! If you’ve completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
MySQL进行登录
[hadoop@note1 ~]$ mysql -uroot -proot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help; ’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>
MySQL就可以正确运行了
Linux状况下也可以开启桌面模式直接进行点击安装更加快捷,包依赖问题都会自动解决,比命令要简单的多。

    推荐阅读