centOS6.5下的MySQL的安裝與配置
1. SSH Secure Shell Client
首先,安裝SSH Secure Shell Client,這是1款連接遠程Linux系統的工具,簡稱SSH客戶端。
在Linux主機上設置好ip地址和端口號以后,打開SSH Client,點擊Quick Connect,填寫遠程服務的ip地址,用戶名(1般默許為root),和端口號。
進入系統后,出現 Add Profile,可以再里面輸入1個名稱作為標識,相當于以后都無需使用用戶名登錄的快捷方式。
2. MySQL
1、安裝
MySQL在剛剛被安裝的時候,它的root用戶是沒有被設置密碼的。首先來設置MySQL的root密碼。
[root@sample ~]# mysql -u root ←用root用戶登錄MySQL服務器
Welcome to the MySQL monitor. Commands end with ;or g.
Your MySQL connection id is 2 to server version: 4.1.20
Type 'help;' or 'h' forhelp. Type 'c' to clear the buffer.
mysql> select user,host,password from mysql.user; ← 查看用戶信息
+------+------------------------------+---------------+
| user | host | password |
+------+------------------------------+---------------+
| root | localhost | | ← root密碼為空
| root | sample.centospub.com | | ← root密碼為空
| | sample.centospub.com | |
| | localhost | |
+------+------------------------------+---------------+
4 rows in set (0.00 sec)
mysql> set password for root@localhost=password('在這里填入root密碼'); ← 設置root密碼
Query OK, 0 rows affected (0.01 sec)
mysql> set password for root@'sample.centospub.com'=password('在這里填入root密碼'); ← 設置root密碼
Query OK, 0 rows affected (0.01 sec)
mysql> select user,host,password from mysql.user; ← 查看用戶信息
+------+-----------------------------------+--------------------------------+
| user | host | password |
+------+-----------------------------------+--------------------------------+
| root | localhost | 19b68057189b027f | ←root密碼被設置
| root | sample.centospub.com | 19b68057189b027f | ←root密碼被設置
| | sample.centospub.com | |
| | localhost | |
+------+-----------------------------------+--------------------------------+
4 rows in set (0.01 sec)
然后,測試1下root密碼有無生效。
[root@sample~]# mysql -u root ← 通過空密碼用root登錄
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:NO) ← 出現此毛病信息說明密碼設置成功
[root@localhost ~]# mysql -u root -h sample.centospub.com ← 通過空密碼用root登錄
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:NO) ← 出現此毛病信息說明密碼設置成功
[root@sample ~]# mysql-u root -p ← 通過密碼用root登錄
Enter password: ← 在這里輸入密碼
Welcome to the MySQL monitor. Commands end with ; or g. ← 確認用密碼能夠成功登錄
Your MySQL connection id is 5 to server version: 4.1.20
Type 'help;' or 'h' forhelp. Type 'c' to clear the buffer.
mysql> exit
Bye
[root@sample ~]# mysql -u root -hsample.centospub.com -p ←通過密碼用root登錄
Enter password: ← 在這里輸入密碼
Welcome to the MySQL monitor. Commands end with ; or g. ← 確認用密碼能夠成功登錄
Your MySQL connection id is 6 to server version: 4.1.20
Type 'help;' or 'h' forhelp. Type 'c' to clear the buffer.
mysql> exit ← 退出MySQL服務器
1旦設置密碼成功以后,以后再登錄使用就不用設置密碼了
直接敲
[root@sample~]# mysql -u root便可。
3. 安裝MySQL Workbench
在這之前,確保你的電腦已安裝
開啟: chkconfig iptables on
關閉:chkconfig iptables off(2)即時生效,重啟后復原(存在安全隱患)
開啟: service iptables start
關閉: service iptables stop
1、開啟端口
方法1:
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT 寫入修改
/etc/init.d/iptables save 保存修改
service iptables restart 重啟防火墻,修改生效
方法2:
vi /etc/sysconfig/iptables 打開配置文件加入以下語句:
-A INPUT -p tcp -m state --state NEW -m tcp --dport3306 -j ACCEPT 重啟防火墻,修改完成
2、關閉端口
方法1:
/sbin/iptables -I INPUT -p tcp --dport3306 -j DROP 寫入修改
/etc/init.d/iptables save 保存修改
service iptables restart 重啟防火墻,修改生效
方法2:
vi /etc/sysconfig/iptables 打開配置文件加入以下語句:
-A INPUT -p tcp -m state --state NEW -m tcp --dport3306 -j DROP 重啟防火墻,修改完成
3、查看端口狀態
/etc/init.d/iptables status
在設置完防火墻以后,1定要重啟防火墻
最后附上MySQL的安裝和配置的.doc文件,(已驗證)的是我操作過的,也是必須的。
上一篇 Libgdx1.5.3發布
下一篇 RGB燈WS2812B