2025-05-25

 

一、測試環境如下:

    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端口已經開啟,說明服務已經啟動,如果沒有啟動可以使用如下命令進行開啟:

    [root@ssbsc mysql]# service mysql start

   Starting MySQL..                                           [  OK  ]

四、登錄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'的主機可以登陸。

 

摘自 寒雪痕的專欄

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *