《MYSQL教程CentOS系統(tǒng)中安裝MySQL和開啟MySQL遠(yuǎn)程訪問的方法》要點(diǎn):
本文介紹了MYSQL教程CentOS系統(tǒng)中安裝MySQL和開啟MySQL遠(yuǎn)程訪問的方法,希望對您有用。如果有疑問,可以聯(lián)系我們。
安裝MySQL
MYSQL必讀
?安裝MySQL和php-mysql
MYSQL必讀
[root@sample ~]# yum -y install mysql-server [root@sample ~]# yum -y install php-mysql
配置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).
? 找到MYSQL必讀
old_passwords=1
這一行,在這一行的下面添加新的規(guī)則,讓MySQL的默認(rèn)編碼為UTF-8,添加MYSQL必讀
default-character-set = utf8
這一行
然后在配置文件的文尾填加如下語句:
[mysql]
MYSQL必讀
default-character-set = utf8
[root@sample ~]# chkconfig mysqld on
[root@sample ~]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@sample ~]#/etc/rc.d/init.d/mysqld start
Initializing MySQL database: [ OK ] Starting MySQL: [ OK ]
開放 MySQL 服務(wù)遠(yuǎn)程訪問MYSQL必讀
修改數(shù)據(jù)庫配置:MYSQL必讀
授權(quán)root用戶進(jìn)行遠(yuǎn)程連接,注意替換 “password” 為 root 用戶真正的密碼:MYSQL必讀
grant all privileges on *.* to root@"%" identified by "password" with grant option; flush privileges;
第二行命令使設(shè)置生效,可以馬上連接.MYSQL必讀
PS:Ubuntu系統(tǒng)下則需要:
MYSQL必讀
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
轉(zhuǎn)載請注明本頁網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/2167.html