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

自动下载安装

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 Resolution

Dependencies Resolved

==============================================================================================================

直到complete

切换到root权限

service mysqld start

或者sudo操作下

[hadoop@note1 ~]$ sudo 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 note1 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  ]


**对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状况下也可以开启桌面模式直接进行点击安装更加快捷,包依赖问题都会自动解决,比命令要简单的多。

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装 MySQL 5.6.32 的步骤如下: 1. 下载 MySQL 5.6.32 的安装包,可以从官网下载:https://dev.mysql.com/downloads/mysql/5.6.html。 2. 进入到下载目录,解压安装包: ``` tar -zxvf mysql-5.6.32-linux-glibc2.5-x86_64.tar.gz ``` 3. 将解压出来的文件移动到安装目录 `/usr/local/mysql`: ``` mv mysql-5.6.32-linux-glibc2.5-x86_64 /usr/local/mysql ``` 4. 创建 MySQL 的数据存储目录: ``` mkdir /usr/local/mysql/data ``` 5. 创建 MySQL 用户和用户组: ``` groupadd mysql useradd -g mysql mysql ``` 6. 修改 MySQL 数据存储目录的权限: ``` chown -R mysql:mysql /usr/local/mysql/data ``` 7. 进入 MySQL 安装目录,初始化 MySQL: ``` cd /usr/local/mysql ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data ``` 8. 修改 MySQL 的配置文件 `/etc/my.cnf`: ``` [client] port = 3306 socket = /tmp/mysql.sock [mysqld] port = 3306 socket = /tmp/mysql.sock datadir = /usr/local/mysql/data user = mysql character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci symbolic-links = 0 [mysqld_safe] log-error = /usr/local/mysql/data/mysql.err pid-file = /usr/local/mysql/data/mysql.pid ``` 9. 启动 MySQL: ``` ./bin/mysqld_safe --user=mysql & ``` 10. 登录 MySQL: ``` ./bin/mysql -uroot -p ``` 第一次登录时,密码为空,直接回车即可。 11. 修改 MySQL 的 root 用户密码: ``` use mysql; update user set password=password('yourpassword') where user='root'; flush privileges; ``` 将 `yourpassword` 替换成你要设置的密码。 至此,MySQL 5.6.32 安装完成。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值