mysql安裝------RPM包安裝及解除安裝

wl365365發表於2015-07-13
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包,下載地址

或者



我這裡的實驗下載的包為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


The latest information about MySQL is available on the web at


 


Support MySQL by buying support/licenses at


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部落格 ” ,連結:http://blog.itpub.net/22039464/viewspace-1731502/,如需轉載,請註明出處,否則將追究法律責任。

相關文章