欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

CentOS系統(tǒng)中安裝MySQL和開啟MySQL遠(yuǎn)程訪問的方法

 更新時間:2016年02月26日 16:49:09   作者:JohnLui  
這篇文章主要介紹了CentOS系統(tǒng)中安裝MySQL和開啟MySQL遠(yuǎn)程訪問的方法,包括MySQL的隨機(jī)啟動等操作的介紹,需要的朋友可以參考下

安裝MySQL

 安裝MySQL和php-mysql

[root@sample ~]# yum -y install mysql-server  
[root@sample ~]# yum -y install php-mysql  

配置MySQL

[root@sample ~]#vim /etc/my.cnf  編輯MySQL的配置文件
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).

  找到

old_passwords=1 

這一行,在這一行的下面添加新的規(guī)則,讓MySQL的默認(rèn)編碼為UTF-8,添加

default-character-set = utf8 

這一行
然后在配置文件的文尾填加如下語句:
[mysql]

default-character-set = utf8

啟動MySQL服務(wù)
[root@sample ~]# chkconfig mysqld on
設(shè)置MySQL服務(wù)隨系統(tǒng)啟動自啟動
[root@sample ~]# chkconfig --list mysqld
確認(rèn)MySQL自啟動
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
   如果2--5為on的狀態(tài)就OK
[root@sample ~]#/etc/rc.d/init.d/mysqld start
啟動MySQL服務(wù)
Initializing MySQL database:         [ OK ]
Starting MySQL:              [ OK ]

開放 MySQL 服務(wù)遠(yuǎn)程訪問

修改數(shù)據(jù)庫配置:

授權(quán)root用戶進(jìn)行遠(yuǎn)程連接,注意替換 “password” 為 root 用戶真正的密碼:

grant all privileges on *.* to root@"%" identified by "password" with grant option;
flush privileges;

第二行命令使設(shè)置生效,可以馬上連接。

PS:Ubuntu系統(tǒng)下則需要:

vim /etc/mysql/my.cnf
找到:
bind-address = 127.0.0.1
改為:
bind-address = 0.0.0.0
#允許任意ip地址訪問
也可以指定IP地址。然后重啟MySQL:
sudo /etc/init.d/mysqld restart

相關(guān)文章

最新評論