Centos mysql 安装及配置

Mysql具有简单易学、体积小等优点,深受编程开发初学者的喜爱
工具/原料

工具/原料

  • 接入Internet的Centos计算机

Centos 6.6下安装Mysql很简单,

yum list mysql-server

当只有一个时候就可以直接

yum install mysql-server


进行安装

过程中选择Y继续安装,最后安装成功

设置Mysql的服务

先启动Mysql服务

service mysqld start

连接一下试一下,直接

mysql
然后
\q
关闭连接

设置Mysql开机启动

chkconfig mysqld on

开启3306端口并保存

/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT

/etc/rc.d/init.d/iptables save

修改密码并设置远程访问

连接mysql数据库

设置密码
use mysql;

update user set password=password('密码') where user='root';

flush privileges;

设置Mysql远程访问

grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

解决Mysql乱码问题

找一个配置文件,复制到/etc/目录,命名为my.cnf

(有时候没有my.cnf)
cp /usr/share/doc/mysql-server-5.1.73/my-medium.cnf /etc/my.cnf

vim my.cnf

在[client]和[mysqld]下面都添加上
default-character-set=utf8

最后按Esc输入

:wq
保存退出

重启mysql服务

最后重新启动服务就可以了

service mysqld restart

相关文章

linux下开机自启: 在/etc/init.d目录下新建文件elasticsear...
1、因为在centos7中/etc/rc.d/rc.local的权限被降低了,所以...
最简单的查看方法可以使用ls -ll、ls-lh命令进行查看,当使用...
ASP.NET Core应用程序发布linux在shell中运行是正常的。可一...
设置时区(CentOS 7) 先执行命令timedatectl status|grep &...
vim /etc/sysconfig/network-scripts/ifcfg-eth0 B...