Home >Database >Mysql Tutorial >MySQL数据库在Linux操作系统上的安装及容易出现的问题

MySQL数据库在Linux操作系统上的安装及容易出现的问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 17:08:301200browse

MySQL数据库在Linux操作系统上的安装及容易出现的问题

一、测试环境如下:

    1、VmwareWorkStation:6.0.2 build-59824

    2、Mysql 数据库的版本:

      服务器端:MySQL-server-5.5.19-1.linux2.6.i386.rpm

      客 户 端:MySQL-client-5.5.19-1.linux2.6.i386.rpm

              3、需要的插件包:libaio-0.3.105-2.i386.rpm

    4、Linux版本:RedHat Linux AS 4

二、执行安装

    1、[root@ssbsc mysql]# rpm -ivh libaio-0.3.105-2.i386.rpm

    2、[root@ssbsc mysql]# rpm -ivh MySQL-server-5.5.19-1.linux2.6.i386.rpm

    3、[root@ssbsc mysql]# rpm -ivh MySQL-client-5.5.19-1.linux2.6.i386.rpm

三、验证

   使用netstat -nat 命令进行验证,看mysql数据库是否已经启动。

   [root@ssbsc mysql]# netstat -nat
   Active Internet connections (servers and established)
   Proto Recv-Q Send-Q Local Address               Foreign Address             State        
   tcp        0      0 :::3306                     :::*                        LISTEN

   观察到Local Address的3306端口已经开启,说明服务已经启动,,如果没有启动可以使用如下命令进行开启:

四、登录MySQL

          登录MySQL的命令是mysql, mysql 的使用语法如下:

   mysql [-u username] [-h host] [-p[password]] [dbname]

   username 与 password 分别是 MySQL 的用户名与密码,mysql的初始管理帐号是root,没有密码。在这里我 设置了密码,所以采用有密码的方式进行登录。

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

     Copyright (c) 2000, 2011, 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>,则证明你已经成功登录了。

五、在Windows 操作系统上利用Navicat for MySQL登录Linux系统上刚才安装的Mysql数据库

通常情况下会遇到的问题:

Error1: 2003:Can't connect to MySQL server on 'localhost'
解决方法:关闭Linux的防火墙功能,或者设置容许TCP协议的3306端口通过,可以下使用如下命令开启TCP协议的3306端口

[root@bugzilla ~]# more /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -p tcp --dport 3306 -j ACCEPT
Error2: 1130 - Host'ClientIP' is not allowed to connect to this MySQL server
解决方法:使用root 用户登陆Linux,登陆MySQL的root用户,更改容许登陆的IP地址范围。

[root@bugzilla ~]# mysql -u root -p
mysql>grant all privileges on *.* to 'root'@'%' identified by 'your password' with grant option;
这段指令容许所有用root用户输入密码登陆该mysql server,如果将'%' 换成'192.168.1.208' ,那么只有'192.168.1.208'的主机可以登陆。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn