[root@sample ~]# yum -y install MysqL-server
[root@sample ~]# yum -y install PHP-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
这一行,在这一行的下面添加新的规则,让MysqL的默认编码为UTF-8,添加
default-character-set = utf8
这一行
然后在配置文件的文尾填加如下语句:
[MysqL]
default-character-set = utf8
[root@sample ~]# chkconfig MysqLd on
设置MysqL服务随系统启动自启动
[root@sample ~]# chkconfig --list MysqLd
确认MysqL自启动
MysqLd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
如果2--5为on的状态就OK
[root@sample ~]#/etc/rc.d/init.d/MysqLd start
Initializing MysqL database: [ OK ]
Starting MysqL: [ OK ]
开放 MysqL 服务远程访问
授权root用户进行远程连接,注意替换 “password” 为 root 用户真正的密码:
grant all privileges on *.* to root@"%" identified by "password" with grant option;
flush privileges;
第二行命令使设置生效,可以马上连接。
PS:Ubuntu系统下则需要:
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
总结
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您喜欢交流学习经验,点击链接加入交流1群:1065694478(已满)交流2群:163560250