ITPub博客

首页 > 数据库 > MySQL > mysql安装------RPM包安装及卸载

mysql安装------RPM包安装及卸载

原创 MySQL 作者:wl365365 时间:2015-07-13 12:50:03 0 删除 编辑
1. 首先检查系统自带是否已经安装了mysql

[root@localhost ~]# rpm -qa|grep mysql
MySQL-client-5.5.25a-1.rhel5
MySQL-server-5.5.25a-1.rhel5

2. 如果存在先删除自带的rpm包
先停止服务
在使用 rpm -e --nodeps 包名
[root@localhost ~]#rpm -e --nodeps MySQL-client-5.5.25a-1.rhel5

3. 删除完之后检查下是否都删除干净了
[root@localhost ~]# rpm -qa|grep mysql

4. 删除之前旧的安装目录
find / -name mysql
查找结果如下:
[root@localhost ~]# find / -name mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/lib64/mysql


删除对应的mysql目录
rm -rf /var/lib/mysql
rm -rf /var/lib/mysql
rm -rf /usr/lib64/mysql


注意:卸载后/etc/my.cnf不会删除,需要进行手工删除
 rm -rf /etc/my.cnf



再次查找机器是否安装mysql


rpm -qa|grep -i mysql
无结果,说明已经卸载彻底、接下来直接安装mysql即可


5. mysql使用RPM包的方式安装
首先下载相应版本的RPM包,下载地址
http://www.mysql.com/downloads/
或者
https://edelivery.oracle.com/


我这里的实验下载的包为V76360-01.zip 里面包含的rpm有:
MySQL-embedded-advanced-5.6.25-1.el6.x86_64.rpm----------------MySQL的嵌入式版本
MySQL-server-advanced-5.6.25-1.el6.x86_64.rpm---------------------MySql的服务器端
MySQL-test-advanced-5.6.25-1.el6.x86_64.rpm------------------------MySql的测试组件
MySQL-client-advanced-5.6.25-1.el6.x86_64.rpm----------------------MySql客户端组件
MySQL-shared-compat-advanced-5.6.25-1.el6.x86_64.rpm----------MySql共享库
MySQL-devel-advanced-5.6.25-1.el6.x86_64.rpm
MySQL-shared-advanced-5.6.25-1.el6.x86_64.rpm


首先我们需要安装server client和devel3个包
[root@localhost install]# rpm -ivh MySQL-client-advanced-5.6.25-1.el6.x86_64.rpmPreparing...                ########################################### [100%]
   1:MySQL-client-advanced  ########################################### [100%]
[root@localhost install]# rpm -ivh MySQL-server-advanced-5.6.25-1.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-server-advanced  ########################################### [100%]
2015-06-10 09:32:43 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-06-10 09:32:43 0 [Note] /usr/sbin/mysqld (mysqld 5.6.25-enterprise-commercial-advanced) starting as process 2776 ...
2015-06-10 09:32:43 2776 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-06-10 09:32:43 2776 [Note] InnoDB: The InnoDB memory heap is disabled
2015-06-10 09:32:43 2776 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-06-10 09:32:43 2776 [Note] InnoDB: Memory barrier is not used
2015-06-10 09:32:43 2776 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-06-10 09:32:43 2776 [Note] InnoDB: Using Linux native AIO
2015-06-10 09:32:43 2776 [Note] InnoDB: Using CPU crc32 instructions
2015-06-10 09:32:43 2776 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-06-10 09:32:43 2776 [Note] InnoDB: Completed initialization of buffer pool
2015-06-10 09:32:43 2776 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2015-06-10 09:32:43 2776 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2015-06-10 09:32:43 2776 [Note] InnoDB: Database physically writes the file full: wait...
2015-06-10 09:32:43 2776 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-06-10 09:32:44 2776 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-06-10 09:32:44 2776 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-06-10 09:32:44 2776 [Warning] InnoDB: New log files created, LSN=45781
2015-06-10 09:32:44 2776 [Note] InnoDB: Doublewrite buffer not found: creating new
2015-06-10 09:32:44 2776 [Note] InnoDB: Doublewrite buffer created
2015-06-10 09:32:44 2776 [Note] InnoDB: 128 rollback segment(s) are active.
2015-06-10 09:32:44 2776 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-06-10 09:32:44 2776 [Note] InnoDB: Foreign key constraint system tables created
2015-06-10 09:32:44 2776 [Note] InnoDB: Creating tablespace and datafile system tables.
2015-06-10 09:32:44 2776 [Note] InnoDB: Tablespace and datafile system tables created.
2015-06-10 09:32:44 2776 [Note] InnoDB: Waiting for purge to start
2015-06-10 09:32:44 2776 [Note] InnoDB: 5.6.25 started; log sequence number 0
2015-06-10 09:32:44 2776 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2015-06-10 09:32:44 2776 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
A random root password has been set. You will find it in '/root/.mysql_secret'.
2015-06-10 09:32:44 2776 [Note] Binlog end
2015-06-10 09:32:44 2776 [Note] InnoDB: FTS optimize thread exiting.
2015-06-10 09:32:44 2776 [Note] InnoDB: Starting shutdown...
2015-06-10 09:32:46 2776 [Note] InnoDB: Shutdown completed; log sequence number 1625977




2015-06-10 09:32:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-06-10 09:32:46 0 [Note] /usr/sbin/mysqld (mysqld 5.6.25-enterprise-commercial-advanced) starting as process 2798 ...
2015-06-10 09:32:46 2798 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-06-10 09:32:46 2798 [Note] InnoDB: The InnoDB memory heap is disabled
2015-06-10 09:32:46 2798 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-06-10 09:32:46 2798 [Note] InnoDB: Memory barrier is not used
2015-06-10 09:32:46 2798 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-06-10 09:32:46 2798 [Note] InnoDB: Using Linux native AIO
2015-06-10 09:32:46 2798 [Note] InnoDB: Using CPU crc32 instructions
2015-06-10 09:32:46 2798 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-06-10 09:32:46 2798 [Note] InnoDB: Completed initialization of buffer pool
2015-06-10 09:32:46 2798 [Note] InnoDB: Highest supported file format is Barracuda.
2015-06-10 09:32:46 2798 [Note] InnoDB: 128 rollback segment(s) are active.
2015-06-10 09:32:46 2798 [Note] InnoDB: Waiting for purge to start
2015-06-10 09:32:46 2798 [Note] InnoDB: 5.6.25 started; log sequence number 1625977
2015-06-10 09:32:46 2798 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2015-06-10 09:32:46 2798 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2015-06-10 09:32:46 2798 [Note] Binlog end
2015-06-10 09:32:46 2798 [Note] InnoDB: FTS optimize thread exiting.
2015-06-10 09:32:46 2798 [Note] InnoDB: Starting shutdown...
2015-06-10 09:32:48 2798 [Note] InnoDB: Shutdown completed; log sequence number 1625987








A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.


You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.


Also, the account for the anonymous user has been removed.


In addition, you can run:


  /usr/bin/mysql_secure_installation


which will also give you the option of removing the test database.
This is strongly recommended for production servers.


See the manual for more instructions.


Please report any problems at http://bugs.mysql.com/


The latest information about MySQL is available on the web at


  http://www.mysql.com


Support MySQL by buying support/licenses at http://shop.mysql.com


New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings



[root@localhost install]# /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): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
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.


You already have a root password set, so you can safely answer 'n'.


Change the root password? [Y/n] Y
New password: 
Re-enter new password: 
Sorry, passwords do not match.


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] n
 ... skipping.


Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.


Reload privilege tables now? [Y/n] Y
 ... Success!








All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.


Thanks for using MySQL!




Cleaning up...


[root@localhost mysqldb]# service mysql start
Starting MySQL.                                            [  OK  ]
[root@localhost mysqldb]# mysql -uroot -proot123
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.25-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)


Copyright (c) 2000, 2015, 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> show tables;
ERROR 1046 (3D000): No database selected
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)






来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22039464/viewspace-1731502/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-07-04

  • 博文量
    29
  • 访问量
    74071