coentos6.5-minimal 安装mysql-5.6.38(rpm安装)

一、官网下载MySQL安装包(red hat版本的rpm安装包)

MySQL-5.6.38-1.el6.x86_64.rpm-bundle.tar官方下载

二、用SecureCRT登录centos系统并在/opt下建立mysql目录

Last login: Wed Jan  3 17:57:52 2018
[root@localhost ~]# mkdir /opt/mysql
[root@localhost ~]# 

三、上传MySQL到服务器(快捷键ALT+P进入上传命令行)

sftp> cd /opt/mysql
sftp> put -r "E:\MySQL-5.6.38-1.el6.x86_64.rpm-bundle.tar"
Uploading MySQL-5.6.38-1.el6.x86_64.rpm-bundle.tar to /opt/mysql/MySQL-5.6.38-1.el6.x86_64.rpm-bundle.tar
  100% 222850KB  31835KB/s 00:00:07     
E:/MySQL-5.6.38-1.el6.x86_64.rpm-bundle.tar: 228198400 bytes transferred in 7 seconds (31835 KB/s)
sftp> 

四、关闭上传命令行并解压MySQL安装包

[root@localhost ~]# cd /opt/mysql
[root@localhost mysql]# ll
总用量 222852
-rw-r--r--. 1 root root 228198400 1月   2 16:45 MySQL-5.6.38-1.el6.x86_64.rpm-bundle.tar
[root@localhost mysql]# tar -xvf MySQL-5.6.38-1.el6.x86_64.rpm-bundle.tar 
MySQL-shared-5.6.38-1.el6.x86_64.rpm
MySQL-devel-5.6.38-1.el6.x86_64.rpm
MySQL-client-5.6.38-1.el6.x86_64.rpm
MySQL-test-5.6.38-1.el6.x86_64.rpm
MySQL-server-5.6.38-1.el6.x86_64.rpm
MySQL-embedded-5.6.38-1.el6.x86_64.rpm
MySQL-shared-compat-5.6.38-1.el6.x86_64.rpm

五、查看当前系统是否安装过MySQL有的话直接删除

[root@localhost mysql]# rpm -qa|grep mysql
mysql-libs-5.1.71-1.el6.x86_64
[root@localhost mysql]# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
[root@localhost mysql]# 
六、安装MySQL依赖包(yum安装,最好把DNS设置成8.8.8.8,不然默认的镜像地址可能会报错)
[root@localhost mysql]# yum install perl -y

[root@localhost mysql]# yum install numactl -y
有时候也会缺少libaio,建议也安装一下,我的已经安装过,没有安装就安装一下
[root@localhost mysql]# yum install libaio -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cn99.com
 * extras: mirrors.163.com
 * updates: mirrors.cn99.com
Setting up Install Process
Package libaio-0.3.107-10.el6.x86_64 already installed and latest version
Nothing to do
[root@localhost mysql]# 
七、安装MySQL服务(MySQL-server)

[root@localhost mysql]# rpm -ivh MySQL-server-5.6.38-1.el6.x86_64.rpm 
warning: MySQL-server-5.6.38-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]
warning: user mysql does not exist - using root
warning: group mysql does not exist - using root
warning: user mysql does not exist - using root
warning: group mysql does not exist - using root
2018-01-03 18:35:37 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-01-03 18:35:37 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-01-03 18:35:37 0 [Note] /usr/sbin/mysqld (mysqld 5.6.38) starting as process 1519 ...
2018-01-03 18:35:37 1519 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-01-03 18:35:37 1519 [Note] InnoDB: The InnoDB memory heap is disabled
2018-01-03 18:35:37 1519 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-01-03 18:35:37 1519 [Note] InnoDB: Memory barrier is not used
2018-01-03 18:35:37 1519 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-01-03 18:35:37 1519 [Note] InnoDB: Using Linux native AIO
2018-01-03 18:35:37 1519 [Note] InnoDB: Using CPU crc32 instructions
2018-01-03 18:35:37 1519 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-01-03 18:35:37 1519 [Note] InnoDB: Completed initialization of buffer pool
2018-01-03 18:35:37 1519 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2018-01-03 18:35:37 1519 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2018-01-03 18:35:37 1519 [Note] InnoDB: Database physically writes the file full: wait...
2018-01-03 18:35:37 1519 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2018-01-03 18:35:39 1519 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2018-01-03 18:35:39 1519 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2018-01-03 18:35:39 1519 [Warning] InnoDB: New log files created, LSN=45781
2018-01-03 18:35:39 1519 [Note] InnoDB: Doublewrite buffer not found: creating new
2018-01-03 18:35:39 1519 [Note] InnoDB: Doublewrite buffer created
2018-01-03 18:35:39 1519 [Note] InnoDB: 128 rollback segment(s) are active.
2018-01-03 18:35:39 1519 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-01-03 18:35:39 1519 [Note] InnoDB: Foreign key constraint system tables created
2018-01-03 18:35:39 1519 [Note] InnoDB: Creating tablespace and datafile system tables.
2018-01-03 18:35:39 1519 [Note] InnoDB: Tablespace and datafile system tables created.
2018-01-03 18:35:39 1519 [Note] InnoDB: Waiting for purge to start
2018-01-03 18:35:39 1519 [Note] InnoDB: 5.6.38 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2018-01-03 18:35:40 1519 [Note] Binlog end
2018-01-03 18:35:40 1519 [Note] InnoDB: FTS optimize thread exiting.
2018-01-03 18:35:40 1519 [Note] InnoDB: Starting shutdown...
2018-01-03 18:35:41 1519 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2018-01-03 18:35:41 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-01-03 18:35:41 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-01-03 18:35:41 0 [Note] /usr/sbin/mysqld (mysqld 5.6.38) starting as process 1541 ...
2018-01-03 18:35:41 1541 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-01-03 18:35:41 1541 [Note] InnoDB: The InnoDB memory heap is disabled
2018-01-03 18:35:41 1541 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-01-03 18:35:41 1541 [Note] InnoDB: Memory barrier is not used
2018-01-03 18:35:41 1541 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-01-03 18:35:41 1541 [Note] InnoDB: Using Linux native AIO
2018-01-03 18:35:41 1541 [Note] InnoDB: Using CPU crc32 instructions
2018-01-03 18:35:41 1541 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-01-03 18:35:41 1541 [Note] InnoDB: Completed initialization of buffer pool
2018-01-03 18:35:41 1541 [Note] InnoDB: Highest supported file format is Barracuda.
2018-01-03 18:35:41 1541 [Note] InnoDB: 128 rollback segment(s) are active.
2018-01-03 18:35:41 1541 [Note] InnoDB: Waiting for purge to start
2018-01-03 18:35:41 1541 [Note] InnoDB: 5.6.38 started; log sequence number 1625977
2018-01-03 18:35:41 1541 [Note] Binlog end
2018-01-03 18:35:41 1541 [Note] InnoDB: FTS optimize thread exiting.
2018-01-03 18:35:41 1541 [Note] InnoDB: Starting shutdown...
2018-01-03 18:35:43 1541 [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

八、安装MySQL-client和MySQL-devel

[root@localhost mysql]# rpm -ivh MySQL-client-5.6.38-1.el6.x86_64.rpm 
warning: MySQL-client-5.6.38-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]
[root@localhost mysql]# rpm -ivh MySQL-devel-5.6.38-1.el6.x86_64.rpm 
warning: MySQL-devel-5.6.38-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-devel            ########################################### [100%]
[root@localhost mysql]#

九、启动MySQL服务

[root@localhost mysql]# service mysql start
Starting MySQL.Logging to '/var/lib/mysql/localhost.localdomain.err'.
 SUCCESS! 
[root@localhost mysql]# 

十、设置MySQL root用户密码,首次进入要使用mysql安装时生成的默认密码  密码在/root/.mysql_secret文件中,具体如下

[root@localhost mysql]# cat /root/.mysql_secret
# The random password set for the root user at Wed Jan  3 18:35:39 2018 (local time): 258yIBbsXldI9Ew1

[root@localhost mysql]# /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.

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

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] y
 ... Success!

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!




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用户登录MySQL

[root@localhost mysql]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.6.38 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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> show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.03 sec)

mysql> set character_set_database=utf8;
Query OK, 0 rows affected (0.00 sec)

mysql> set character_set_server=utf8
    -> ;
Query OK, 0 rows affected (0.00 sec)

mysql> 

十三、设置root用户可以从任意主机登录(注意将hadoop换成自己的密码)

mysql> grant all privileges on *.* to root@"%" identified by "hadoop" with grant option;
Query OK, 0 rows affected (0.03 sec)

mysql> 

十四、退出并重启mysql服务

mysql> quit;
Bye
[root@localhost mysql]# service mysql restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL. SUCCESS! 
[root@localhost mysql]# 
十五、设置防火墙开放mysql端口3306
[root@localhost mysql]# /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
[root@localhost mysql]# /etc/rc.d/init.d/iptables save
iptables:将防火墙规则保存到 /etc/sysconfig/iptables:     [确定]
[root@localhost mysql]# /etc/init.d/iptables restart
iptables:将链设置为政策 ACCEPT:filter                    [确定]
iptables:清除防火墙规则:                                 [确定]
iptables:正在卸载模块:                                   [确定]
iptables:应用防火墙规则:                                 [确定]
[root@localhost mysql]# 








  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值