简单安装mysql
注意安装前,需安装yum包
1、centos系统中使用yum安装mariadb
# yum -y install mariadb-server
2、安装完成后,修改my.cnf配置文件
# vi /etc/my.cnf
mysqld 后增加默认字符集设置
character-set-server=utf8
3、配置完成后,启动mariadb
#systemctl start mariadb 启动mariadb
# netstat -nltp 查看启动是否成功
4、设置开机自启动
# systemctl enable mariadb #设置开机启动
5、初始设置MariaDB(安全设置)
# mysql_secure_installation #初始设置MariaDB(安全设置)
6、登录mysql
# mysql -u root -p +密码
>select user,host,password from mysql.user; #查看mysql用户相关信息
>show databases; #查看mysql当前数据库
>exit 退出mysql
7、防火墙设置
# firewall-cmd –add-service=mysql –permanent #防火墙添加3306/TCP端口
# firewall-cmd –reload 重启防火墙
8、my.cnf 配置示例
conf: # /etc/my.cnf
[root@localhost /var/lib/mysql]# cat /etc/my.cnf |grep -v “^#” |grep -v “^$”
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
character-set-server=utf8
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
!includedir /etc/my.cnf.d