Installing MySQL on Linux6 Using the MySQL Yum Repository

孤竹星發表於2015-04-13
r作業系統:rhel6 

1. 下載yum包 

下載地址:
http://dev.mysql.com/downloads/repo/yum/

2. 選擇下載對應的平臺的包

[root@root home]# sudo yum localinstall mysql-community-release-el6-5.noarch.rpm 
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Local Package Process
Examining mysql-community-release-el6-5.noarch.rpm: mysql-community-release-el6-5.noarch
Marking mysql-community-release-el6-5.noarch.rpm to be installed
Loading mirror speeds from cached hostfile
Resolving Dependencies
--&gt Running transaction check
---&gt Package mysql-community-release.noarch 0:el6-5 will be installed
--&gt Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================
 Package                      Arch        Version     Repository                                  Size
=======================================================================================================
Installing:
 mysql-community-release      noarch      el6-5       /mysql-community-release-el6-5.noarch      4.3 k


Transaction Summary
=======================================================================================================
Install       1 Package(s)

Total size: 4.3 k
Installed size: 4.3 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mysql-community-release-el6-5.noarch                                                1/1 
  Verifying  : mysql-community-release-el6-5.noarch                                                1/1 

Installed:
  mysql-community-release.noarch 0:el6-5                                                               

Complete!

3. 檢查Mysql yum repository 是否新增成功

[root@root home]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community           MySQL Connectors Community            13
mysql-tools-community                MySQL Tools Community                 21
mysql56-community                    MySQL 5.6 Community Server           146

4. 安裝命令

[root@root home]# sudo yum install mysql-community-server
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--&gt Running transaction check
---&gt Package mysql-community-server.x86_64 0:5.6.24-3.el6 will be installed
--&gt Processing Dependency: mysql-community-common(x86-64) = 5.6.24-3.el6 for package: mysql-community-server-5.6.24-3.el6.x86_64
--&gt Processing Dependency: mysql-community-client(x86-64) = 5.6.24-3.el6 for package: mysql-community-server-5.6.24-3.el6.x86_64
--&gt Running transaction check
---&gt Package mysql-community-client.x86_64 0:5.6.24-3.el6 will be installed
--&gt Processing Dependency: mysql-community-libs(x86-64) = 5.6.24-3.el6 for package: mysql-community-client-5.6.24-3.el6.x86_64
---&gt Package mysql-community-common.x86_64 0:5.6.24-3.el6 will be installed
--&gt Running transaction check
---&gt Package mysql-community-libs.x86_64 0:5.6.24-3.el6 will be installed
--&gt Finished Dependency Resolution


Dependencies Resolved


=======================================================================================================
 Package                        Arch           Version                 Repository                 Size
=======================================================================================================
Installing:
 mysql-community-server         x86_64         5.6.24-3.el6            mysql56-community          53 M
Installing for dependencies:
 mysql-community-client         x86_64         5.6.24-3.el6            mysql56-community          18 M
 mysql-community-common         x86_64         5.6.24-3.el6            mysql56-community         307 k
 mysql-community-libs           x86_64         5.6.24-3.el6            mysql56-community         1.9 M


Transaction Summary
=======================================================================================================
Install       4 Package(s)


Total download size: 73 M
Installed size: 328 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): mysql-community-client-5.6.24-3.el6.x86_64.rpm                           |  18 MB     03:00     
(2/4): mysql-community-common-5.6.24-3.el6.x86_64.rpm                           | 307 kB     00:02     
(3/4): mysql-community-libs-5.6.24-3.el6.x86_64.rpm                             | 1.9 MB     00:21     
(4/4): mysql-community-server-5.6.24-3.el6.x86_64.rpm                           |  53 MB     08:53     
-------------------------------------------------------------------------------------------------------
Total                                                                  101 kB/s |  73 MB     12:18     
warning: rpmts_HdrFromFdno: V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Retrieving key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid : MySQL Release Engineering
 Package: mysql-community-release-el6-5.noarch (@/mysql-community-release-el6-5.noarch)
 From   : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mysql-community-common-5.6.24-3.el6.x86_64                                          1/4 
  Installing : mysql-community-libs-5.6.24-3.el6.x86_64                                            2/4 
  Installing : mysql-community-client-5.6.24-3.el6.x86_64                                          3/4 
  Installing : mysql-community-server-5.6.24-3.el6.x86_64                                          4/4 
  Verifying  : mysql-community-server-5.6.24-3.el6.x86_64                                          1/4 
  Verifying  : mysql-community-libs-5.6.24-3.el6.x86_64                                            2/4 
  Verifying  : mysql-community-common-5.6.24-3.el6.x86_64                                          3/4 
  Verifying  : mysql-community-client-5.6.24-3.el6.x86_64                                          4/4 

Installed:
  mysql-community-server.x86_64 0:5.6.24-3.el6                                                         

Dependency Installed:
  mysql-community-client.x86_64 0:5.6.24-3.el6       mysql-community-common.x86_64 0:5.6.24-3.el6      
  mysql-community-libs.x86_64 0:5.6.24-3.el6        

Complete!

5. 啟動和停止mysql服務

第一次啟動
[root@root home]# sudo service mysqld start
?????? MySQL ???????? 2015-04-10 18:56:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-04-10 18:56:46 0 [Note] /usr/sbin/mysqld (mysqld 5.6.24) starting as process 27394 ...
2015-04-10 18:56:46 27394 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-04-10 18:56:46 27394 [Note] InnoDB: The InnoDB memory heap is disabled
2015-04-10 18:56:46 27394 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-04-10 18:56:46 27394 [Note] InnoDB: Memory barrier is not used
2015-04-10 18:56:46 27394 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-04-10 18:56:46 27394 [Note] InnoDB: Using Linux native AIO
2015-04-10 18:56:46 27394 [Note] InnoDB: Not using CPU crc32 instructions
2015-04-10 18:56:46 27394 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-04-10 18:56:46 27394 [Note] InnoDB: Completed initialization of buffer pool
2015-04-10 18:56:46 27394 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2015-04-10 18:56:46 27394 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2015-04-10 18:56:46 27394 [Note] InnoDB: Database physically writes the file full: wait...
2015-04-10 18:56:46 27394 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-04-10 18:56:46 27394 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-04-10 18:56:47 27394 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-04-10 18:56:47 27394 [Warning] InnoDB: New log files created, LSN=45781
2015-04-10 18:56:47 27394 [Note] InnoDB: Doublewrite buffer not found: creating new
2015-04-10 18:56:47 27394 [Note] InnoDB: Doublewrite buffer created
2015-04-10 18:56:47 27394 [Note] InnoDB: 128 rollback segment(s) are active.
2015-04-10 18:56:47 27394 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-04-10 18:56:47 27394 [Note] InnoDB: Foreign key constraint system tables created
2015-04-10 18:56:47 27394 [Note] InnoDB: Creating tablespace and datafile system tables.
2015-04-10 18:56:47 27394 [Note] InnoDB: Tablespace and datafile system tables created.
2015-04-10 18:56:47 27394 [Note] InnoDB: Waiting for purge to start
2015-04-10 18:56:47 27394 [Note] InnoDB: 5.6.24 started; log sequence number 0
2015-04-10 18:56:49 27394 [Note] Binlog end
2015-04-10 18:56:49 27394 [Note] InnoDB: FTS optimize thread exiting.
2015-04-10 18:56:49 27394 [Note] InnoDB: Starting shutdown...
2015-04-10 18:56:50 27394 [Note] InnoDB: Shutdown completed; log sequence number 1625977




2015-04-10 18:56:50 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-04-10 18:56:50 0 [Note] /usr/sbin/mysqld (mysqld 5.6.24) starting as process 27417 ...
2015-04-10 18:56:50 27417 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-04-10 18:56:50 27417 [Note] InnoDB: The InnoDB memory heap is disabled
2015-04-10 18:56:50 27417 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-04-10 18:56:50 27417 [Note] InnoDB: Memory barrier is not used
2015-04-10 18:56:50 27417 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-04-10 18:56:50 27417 [Note] InnoDB: Using Linux native AIO
2015-04-10 18:56:50 27417 [Note] InnoDB: Not using CPU crc32 instructions
2015-04-10 18:56:50 27417 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-04-10 18:56:50 27417 [Note] InnoDB: Completed initialization of buffer pool
2015-04-10 18:56:50 27417 [Note] InnoDB: Highest supported file format is Barracuda.
2015-04-10 18:56:50 27417 [Note] InnoDB: 128 rollback segment(s) are active.
2015-04-10 18:56:50 27417 [Note] InnoDB: Waiting for purge to start
2015-04-10 18:56:50 27417 [Note] InnoDB: 5.6.24 started; log sequence number 1625977
2015-04-10 18:56:51 27417 [Note] Binlog end
2015-04-10 18:56:51 27417 [Note] InnoDB: FTS optimize thread exiting.
2015-04-10 18:56:51 27417 [Note] InnoDB: Starting shutdown...
2015-04-10 18:56:52 27417 [Note] InnoDB: Shutdown completed; log sequence number 1625987








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 root 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.


Please report any problems at


The latest information about MySQL is available on the web at


 


Support MySQL by buying support/licenses at


Note: new default config file not created.
Please make sure your config file is current


WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server


[?·?¨]


???????? mysqld?? [?·?¨]


[root@root home]# sudo service mysqld start
正在啟動 mysqld:[確定]
[root@root home]# sudo service mysqld status
mysqld (pid  16573) 正在執行
[root@root home]# sudo service mysqld stop
停止 mysqld:  [確定]

6. 進入mysql
[root@root home]# su - mysql
-bash-4.1$ mysql
mysql: Unknown OS character set 'GB18030'.
mysql: Switching to the default character set 'latin1'.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.24 MySQL Community Server (GPL)


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 databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.02 sec)

建立test資料庫
mysql> create database test;
Query OK, 1 row affected (0.02 sec)

使用建立的test資料庫
mysql> use test;
Database changed
mysql> show tables;
Empty set (0.00 sec)

建立表test
mysql> create table test (id int,name varchar(20));
Query OK, 0 rows affected (0.10 sec)


mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| test           |
+----------------+
1 row in set (0.00 sec)

mysql> exit
Bye
-bash-4.1$ exit
logout

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28282660/viewspace-1571384/,如需轉載,請註明出處,否則將追究法律責任。

相關文章