《MYSQL教程CentOS系統中安裝MySQL和開啟MySQL遠程訪問的方法》要點:
本文介紹了MYSQL教程CentOS系統中安裝MySQL和開啟MySQL遠程訪問的方法,希望對您有用。如果有疑問,可以聯系我們。
安裝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
這一行,在這一行的下面添加新的規則,讓MySQL的默認編碼為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 服務遠程訪問MYSQL必讀
修改數據庫配置:MYSQL必讀
授權root用戶進行遠程連接,注意替換 “password” 為 root 用戶真正的密碼:MYSQL必讀
grant all privileges on *.* to root@"%" identified by "password" with grant option; flush privileges;
第二行命令使設置生效,可以馬上連接.MYSQL必讀
PS:Ubuntu系統下則需要:
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
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/2167.html