liunx-Centos6-mysql-xshell互通

本文主要讲解如何在Centos6的linux系统安装mysql并实现在windows桌面下使用xshell远程连接linux操作mysql数据库。

第一步、卸载linux下的mysql数据库。

1.1 查看与mysql相关的服务

[root@bogon ~]# rpm -qa |grep -i mysql

mysql-5.1.73-8.el6_8.x86_64

mysql-server-5.1.73-8.el6_8.x86_64

mysql-libs-5.1.73-8.el6_8.x86_64

mysql-devel-5.1.73-8.el6_8.x86_64

perl-DBD-MySQL-4.013-3.el6.x86_64

1.2 卸载这些服务

[root@bogon ~]# rpm -ev --nodeps  mysql-5.1.73-8.el6_8.x86_64

[root@bogon ~]# rpm -ev --nodeps  mysql-server-5.1.73-8.el6_8.x86_64

warning: /var/log/mysqld.log saved as /var/log/mysqld.log.rpmsave

[root@bogon ~]# rpm -ev --nodeps  mysql-libs-5.1.73-8.el6_8.x86_64

[root@bogon ~]# rpm -ev --nodeps  mysql-devel-5.1.73-8.el6_8.x86_64

[root@bogon ~]# rpm -ev --nodeps  perl-DBD-MySQL-4.013-3.el6.x86_64

1.3 查看与mysql相关的文件夹

[root@bogon ~]# find / -name mysql

/usr/lib64/perl5/auto/DBD/mysql

/usr/lib64/perl5/DBD/mysql

/usr/lib64/mysql

/usr/include/mysql

/usr/share/mysql

/usr/bin/mysql

/var/lib/mysql

/var/lib/mysql/mysql

1.4 删除这些文件夹

[root@bogon ~]# rm -rf  /usr/lib64/perl5/auto/DBD/mysql

[root@bogon ~]# rm -rf  /usr/lib64/perl5/DBD/mysql

[root@bogon ~]# rm -rf  /usr/lib64/mysql

[root@bogon ~]# rm -rf  /usr/include/mysql

[root@bogon ~]# rm -rf  /usr/share/mysql

[root@bogon ~]# rm -rf  /usr/bin/mysql

[root@bogon ~]# rm -rf  /var/lib/mysql

[root@bogon ~]# rm -rf  /var/lib/mysql/mysql

第二步、安装mysql数据库

2.1 使用yum指令 yum list | grep mysql查看可以安装的mysql版本信息

yum list | grep mysql

mysql.x86_64                      5.1.73-8.el6_8              @base           

mysql-devel.x86_64                5.1.73-8.el6_8              @base           

mysql-libs.x86_64                  5.1.73-8.el6_8              @base           

mysql-server.x86_64                5.1.73-8.el6_8              @base           

apr-util-mysql.x86_64              1.3.9-3.el6_0.1            base           

bacula-director-mysql.x86_64      5.0.0-13.el6                base           

bacula-storage-mysql.x86_64        5.0.0-13.el6                base           

dovecot-mysql.x86_64              1:2.0.9-22.el6              base           

freeradius-mysql.x86_64            2.2.6-7.el6_9              base           

libdbi-dbd-mysql.x86_64            0.8.3-5.1.el6              base           

mod_auth_mysql.x86_64              1:3.0.0-11.el6_0.1          base           

mysql-bench.x86_64                5.1.73-8.el6_8              base           

mysql-connector-java.noarch        1:5.1.17-6.el6              base           

mysql-connector-odbc.x86_64        5.1.5r1144-7.el6            base           

mysql-devel.i686                  5.1.73-8.el6_8              base           

mysql-embedded.i686                5.1.73-8.el6_8              base           

mysql-embedded.x86_64              5.1.73-8.el6_8              base           

mysql-embedded-devel.i686          5.1.73-8.el6_8              base           

mysql-embedded-devel.x86_64        5.1.73-8.el6_8              base           

mysql-libs.i686                    5.1.73-8.el6_8              base           

mysql-test.x86_64                  5.1.73-8.el6_8              base           

pcp-pmda-mysql.x86_64              3.10.9-9.el6                base           

php-mysql.x86_64                  5.3.3-49.el6                base           

qt-mysql.i686                      1:4.6.2-28.el6_5            base         

qt-mysql.x86_64                    1:4.6.2-28.el6_5            base         

rsyslog-mysql.x86_64              5.8.10-12.el6              base           

rsyslog7-mysql.x86_64              7.4.10-7.el6                base 

2.2 安装mysql数据库使用yum install -y mysql-server mysql mysql-devel指令自动安装mysql数据库及所需要的服务。

yum install -y mysql-server mysql mysql-devel

Loaded plugins: fastestmirror, refresh-packagekit, security

Setting up Install Process

Loading mirror speeds from cached hostfile

* base: 欢迎访问网易开源镜像站

* extras: 欢迎访问网易开源镜像站

* updates: 兰州大学开源社区镜像站

Resolving Dependencies

--> Running transaction check

---> Package mysql.x86_64 0:5.1.73-8.el6_8 will be installed

--> Processing Dependency: mysql-libs = 5.1.73-8.el6_8 for package: mysql-5.1.73-8.el6_8.x86_64

--> Processing Dependency: libmysqlclient_r.so.16(libmysqlclient_16)(64bit) for package: mysql-5.1.73-8.el6_8.x86_64

--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: mysql-5.1.73-8.el6_8.x86_64

--> Processing Dependency: libmysqlclient_r.so.16()(64bit) for package: mysql-5.1.73-8.el6_8.x86_64

--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: mysql-5.1.73-8.el6_8.x86_64

---> Package mysql-devel.x86_64 0:5.1.73-8.el6_8 will be installed

---> Package mysql-server.x86_64 0:5.1.73-8.el6_8 will be installed

--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.73-8.el6_8.x86_64

--> Running transaction check

---> Package mysql-libs.x86_64 0:5.1.73-8.el6_8 will be installed

---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================================================

Package                                          Arch                                      Version                                            Repository                              Size

===============================================================================================================================================================================================

Installing:

mysql                                            x86_64                                    5.1.73-8.el6_8                                      base                                    895 k

mysql-devel                                      x86_64                                    5.1.73-8.el6_8                                      base                                    130 k

mysql-server                                      x86_64                                    5.1.73-8.el6_8                                      base                                    8.6 M

Installing for dependencies:

mysql-libs                                        x86_64                                    5.1.73-8.el6_8                                      base                                    1.2 M

perl-DBD-MySQL                                    x86_64                                    4.013-3.el6                                        base                                    134 k

Transaction Summary

===============================================================================================================================================================================================

Install      5 Package(s)

Total download size: 11 M

Installed size: 32 M

Downloading Packages:

(1/5): mysql-5.1.73-8.el6_8.x86_64.rpm                                                                                                                                  | 895 kB    00:00   

(2/5): mysql-devel-5.1.73-8.el6_8.x86_64.rpm                                                                                                                            | 130 kB    00:00   

(3/5): mysql-libs-5.1.73-8.el6_8.x86_64.rpm                                                                                                                            | 1.2 MB    00:00   

(4/5): mysql-server-5.1.73-8.el6_8.x86_64.rpm                                                                                                                          | 8.6 MB    00:03   

(5/5): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm                                                                                                                            | 134 kB    00:00   

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Total                                                                                                                                                          2.2 MB/s |  11 MB    00:04   

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Warning: RPMDB altered outside of yum.

** Found 7 pre-existing rpmdb problem(s), 'yum check' output follows:

akonadi-1.2.1-3.el6.x86_64 has missing requires of mysql-server

akonadi-1.2.1-3.el6.x86_64 has missing requires of qt4-mysql

2:postfix-2.6.6-8.el6.x86_64 has missing requires of libmysqlclient.so.16()(64bit)

2:postfix-2.6.6-8.el6.x86_64 has missing requires of libmysqlclient.so.16(libmysqlclient_16)(64bit)

2:postfix-2.6.6-8.el6.x86_64 has missing requires of mysql-libs

redland-1.0.7-11.el6.x86_64 has missing requires of libmysqlclient.so.16()(64bit)

redland-1.0.7-11.el6.x86_64 has missing requires of libmysqlclient.so.16(libmysqlclient_16)(64bit)

  Installing : mysql-libs-5.1.73-8.el6_8.x86_64                                                                                                                                            1/5

  Installing : mysql-5.1.73-8.el6_8.x86_64                                                                                                                                                2/5

  Installing : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                                                                                          3/5

  Installing : mysql-server-5.1.73-8.el6_8.x86_64                                                                                                                                          4/5

  Installing : mysql-devel-5.1.73-8.el6_8.x86_64                                                                                                                                          5/5

  Verifying  : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                                                                                          1/5

  Verifying  : mysql-server-5.1.73-8.el6_8.x86_64                                                                                                                                          2/5

  Verifying  : mysql-5.1.73-8.el6_8.x86_64                                                                                                                                                3/5

  Verifying  : mysql-devel-5.1.73-8.el6_8.x86_64                                                                                                                                          4/5

  Verifying  : mysql-libs-5.1.73-8.el6_8.x86_64                                                                                                                                            5/5

Installed:

  mysql.x86_64 0:5.1.73-8.el6_8                              mysql-devel.x86_64 0:5.1.73-8.el6_8                              mysql-server.x86_64 0:5.1.73-8.el6_8                           

Dependency Installed:

  mysql-libs.x86_64 0:5.1.73-8.el6_8                                                            perl-DBD-MySQL.x86_64 0:4.013-3.el6                                                         

Complete!

2.3 首次开启mysql服务

[root@bogon ~]# service mysqld start

Initializing MySQL database:  WARNING: The host 'bogon' could not be looked up with resolveip.

This probably means that your libc libraries are not 100 % compatible

with this binary MySQL version. The MySQL daemon, mysqld, should work

normally with the exception that host name resolving will not work.

This means that you should use IP addresses instead of hostnames

when specifying MySQL privileges !

Installing MySQL system tables...

OK

Filling help tables...

OK

To start mysqld at boot time you have to copy

support-files/mysql.server to the right place for your system

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

You can start the MySQL daemon with:

cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

                                                          [  OK  ]

Starting mysqld:                                          [  OK  ]

2.4 设置root密码重启服务。

[root@bogon ~]# mysqladmin -u root password '123456'

[root@bogon ~]# service  mysqld restart

Stopping mysqld:                                          [  OK  ]

Starting mysqld:                                          [  OK  ]

2.5 测试mysql数据库是否安装成功。

进入mysql

[root@bogon ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.1.73 Source distribution

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

| test              |

+--------------------+

3 rows in set (0.01 sec)

mysql> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> show tables;

+---------------------------+

| Tables_in_mysql          |

+---------------------------+

| columns_priv              |

| db                        |

| event                    |

| func                      |

| general_log              |

| help_category            |

| help_keyword              |

| help_relation            |

| help_topic                |

| host                      |

| ndb_binlog_index          |

| plugin                    |

| proc                      |

| procs_priv                |

| servers                  |

| slow_log                  |

| tables_priv              |

| time_zone                |

| time_zone_leap_second    |

| time_zone_name            |

| time_zone_transition      |

| time_zone_transition_type |

| user                      |

+---------------------------+

23 rows in set (0.00 sec)

mysql> select host,user from user;

+-----------+------+

| host      | user |

+-----------+------+

| %        | root |

| 127.0.0.1 | root |

| bogon    |      |

| bogon    | root |

| localhost |      |

| localhost | root |

+-----------+------+

6 rows in set (0.00 sec)

2.6 设置mysql允许远程连接

mysql> GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

Query OK, 0 rows affected (0.00 sec)

mysql> select host,user from user;

+-----------+------+

| host      | user |

+-----------+------+

| %        | root |

| 127.0.0.1 | root |

| bogon    |      |

| bogon    | root |

| localhost |      |

| localhost | root |

+-----------+------+

6 rows in set (0.00 sec)

2.7 设置防火墙  vi /etc/sysconfig/iptables

# Firewall configuration written by system-config-firewall

# Manual customization of this file is not recommended.

*filter

:INPUT ACCEPT [0:0]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [0:0]

-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

-A INPUT -p icmp -j ACCEPT

-A INPUT -i lo -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT

-A INPUT -j REJECT --reject-with icmp-host-prohibited

-A FORWARD -j REJECT --reject-with icmp-host-prohibited

COMMIT

~                                                                                                                                                                                           

                                                                                                                                                                                         

"/etc/sysconfig/iptables" 14L, 543C

2.8 重启服务 service iptables restart

[root@bogon ~]# service iptables restart

iptables: Setting chains to policy ACCEPT: filter          [  OK  ]

iptables: Flushing firewall rules:                        [  OK  ]

iptables: Unloading modules:                              [  OK  ]

iptables: Applying firewall rules:                        [  OK  ]

第三步、在linux中安装wget来实现xshell远程访问linux。

3.1 安装wget

[root@bogon ~]# yum -y install wget

3.2 安装客户端和服务器

yum  -y install openssh openssh-clients openssh-server

3.3 开启ssh

/etc/init.d/sshd start

3.4 开启ftp

/etc/init.d/vsftpd restart

第四步:测试xshell连接

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,744评论 6 502
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,505评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 163,105评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,242评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,269评论 6 389
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,215评论 1 299
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,096评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,939评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,354评论 1 311
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,573评论 2 333
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,745评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,448评论 5 344
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,048评论 3 327
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,683评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,838评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,776评论 2 369
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,652评论 2 354

推荐阅读更多精彩内容