Mysql 基础篇 --- yum和rpm安装详解

###1. Mysql 服务器安装

####1.1 yum 安装Mysql数据库

yum 安装:

# yum install mysql database server
# check the old mysql patch
[root@tonytest ~]# yum list installed mysql*
[root@tonytest ~]# rpm -qa | grep mysql*

# if you have old mysql patch, please remove it
[root@tonytest ~]# rpm -e --allmatches mysql-5.0.95-5.el5_9

#check the mysql patch on the yum repo
[root@tonytest ~]# yum list mysql*

# install the mysql client
[root@tonytest ~]# yum install mysql
Dependencies Resolved
================================================================================
 Package         Arch             Version                  Repository      Size
================================================================================
Installing:
 mysql           i386             5.0.95-5.el5_9           base           4.9 M
 mysql           x86_64           5.0.95-5.el5_9           base           4.9 M

Transaction Summary
================================================================================

[root@tonytest ~]# yum install mysql-devel

#install the mysql server
[root@tonytest ~]# yum install mysql-server
Dependencies Resolved
================================================================================
 Package               Arch          Version                  Repository   Size
================================================================================
Installing:
 mysql-server          x86_64        5.0.95-5.el5_9           base        9.9 M
Installing for dependencies:
 perl-DBD-MySQL        x86_64        3.0007-2.el5             base        148 k

#startup the mysql database
[root@tonytest ~]# /etc/init.d/mysqld start

#modify the root password
[root@tonytest ~]# /usr/bin/mysqladmin -u root password 'pass'



####1.2 rpm 安装Mysql数据库

rpm 安装:

http://dev.mysql.com/downloads/mysql/
[root@mydb1 mysql]# ll
total 111476
-rwx------ 1 root root 23163988 Dec 16 09:20 MySQL-client-5.6.22-1.linux_glibc2.5.x86_64.rpm
-rwx------ 1 root root 88568583 Dec 16 09:20 MySQL-server-5.6.22-1.linux_glibc2.5.x86_64.rpm
-rwx------ 1 root root  2412480 Dec 16 09:20 MySQL-shared-5.6.22-1.linux_glibc2.5.x86_64.rpm


如果安装MySQL软件包时出现从属错误(例如,“error: removing these packages would break dependencies: libmysqlclient.so.10 is needed by ..”),你还应当安装包MySQL-shared-compat,其中包括两个向后兼容的共享库(MySQL 4.0为libmysqlclient.so.12,MySQL 3.23为libmysqlclient.so.10)。

[root@mydb1 mysql]# rpm -ivh MySQL-server-5.6.22-1.linux_glibc2.5.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]
[root@mydb1 mysql]# rpm -ivh MySQL-client-5.6.22-1.linux_glibc2.5.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]
   
[root@mydb1 mysql]# rpm -ivh MySQL-server-5.6.22-1.linux_glibc2.5.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]
2014-12-16 10:07:00 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-12-16 10:07:00 12887 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-12-16 10:07:00 12887 [Note] InnoDB: The InnoDB memory heap is disabled
2014-12-16 10:07:00 12887 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-12-16 10:07:00 12887 [Note] InnoDB: Memory barrier is not used
2014-12-16 10:07:00 12887 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-12-16 10:07:00 12887 [Note] InnoDB: Using Linux native AIO
2014-12-16 10:07:00 12887 [Note] InnoDB: Using CPU crc32 instructions
2014-12-16 10:07:00 12887 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-12-16 10:07:00 12887 [Note] InnoDB: Completed initialization of buffer pool
2014-12-16 10:07:00 12887 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2014-12-16 10:07:00 12887 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2014-12-16 10:07:00 12887 [Note] InnoDB: Database physically writes the file full: wait...
2014-12-16 10:07:00 12887 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2014-12-16 10:07:01 12887 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2014-12-16 10:07:01 12887 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2014-12-16 10:07:01 12887 [Warning] InnoDB: New log files created, LSN=45781
2014-12-16 10:07:01 12887 [Note] InnoDB: Doublewrite buffer not found: creating new
2014-12-16 10:07:01 12887 [Note] InnoDB: Doublewrite buffer created
2014-12-16 10:07:01 12887 [Note] InnoDB: 128 rollback segment(s) are active.
2014-12-16 10:07:01 12887 [Warning] InnoDB: Creating foreign key constraint system tables.
2014-12-16 10:07:01 12887 [Note] InnoDB: Foreign key constraint system tables created
2014-12-16 10:07:01 12887 [Note] InnoDB: Creating tablespace and datafile system tables.
2014-12-16 10:07:01 12887 [Note] InnoDB: Tablespace and datafile system tables created.
2014-12-16 10:07:01 12887 [Note] InnoDB: Waiting for purge to start
2014-12-16 10:07:01 12887 [Note] InnoDB: 5.6.22 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2014-12-16 10:07:02 12887 [Note] Binlog end
2014-12-16 10:07:02 12887 [Note] InnoDB: FTS optimize thread exiting.
2014-12-16 10:07:02 12887 [Note] InnoDB: Starting shutdown...
2014-12-16 10:07:03 12887 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2014-12-16 10:07:03 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-12-16 10:07:03 12909 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-12-16 10:07:03 12909 [Note] InnoDB: The InnoDB memory heap is disabled
2014-12-16 10:07:03 12909 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-12-16 10:07:03 12909 [Note] InnoDB: Memory barrier is not used
2014-12-16 10:07:03 12909 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-12-16 10:07:03 12909 [Note] InnoDB: Using Linux native AIO
2014-12-16 10:07:03 12909 [Note] InnoDB: Using CPU crc32 instructions
2014-12-16 10:07:03 12909 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-12-16 10:07:03 12909 [Note] InnoDB: Completed initialization of buffer pool
2014-12-16 10:07:03 12909 [Note] InnoDB: Highest supported file format is Barracuda.
2014-12-16 10:07:03 12909 [Note] InnoDB: 128 rollback segment(s) are active.
2014-12-16 10:07:03 12909 [Note] InnoDB: Waiting for purge to start
2014-12-16 10:07:03 12909 [Note] InnoDB: 5.6.22 started; log sequence number 1625977
2014-12-16 10:07:03 12909 [Note] Binlog end
2014-12-16 10:07:03 12909 [Note] InnoDB: FTS optimize thread exiting.
2014-12-16 10:07:03 12909 [Note] InnoDB: Starting shutdown...
2014-12-16 10:07:05 12909 [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

WARNING: Found existing config file /usr/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/my-new.cnf,
please compare it with your file and take the changes you need.

[root@mydb1 mysql]# rpm -ivh MySQL-client-5.6.22-1.linux_glibc2.5.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]

[root@mydb1 mysql]# more /root/.mysql_secret
# The random password set for the root user at Tue Dec 16 10:07:02 2014 (local time): XZLUY_kM6jQEJrUf

[root@mydb1 mysql]# mysql -u root -p
Enter password:XZLUY_kM6jQEJrUf
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.22

Copyright (c) 2000, 2014, 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> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('pass');
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit

[root@mydb1 mysql]# mysql -u root -ppass
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 2
Server version: 5.6.22 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, 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> exit


转载于:https://my.oschina.net/wangbinbin0326/blog/466578

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值