Linux的mysql 数据库及开发包安装

81 篇文章 2 订阅
10 篇文章 0 订阅
该文指导用户以root权限通过yum命令安装MariaDB、MariaDB-server和MariaDB-devel。接着,它详细说明了如何修改配置文件,如client.cnf、mysql-clients.cnf和server.cnf,以设置默认字符集为utf8。然后,文章展示了如何启动MariaDB服务,设置其开机自启,并检查服务状态。最后,验证了MySQL连接成功。
摘要由CSDN通过智能技术生成

注意:以下操作都以 root 用户进行操作

直接按照下列步骤在命令行输入即可
下载
1:

sudo yum install -y mariadb

2:

sudo yum install -y mariadb-server

3:

sudo yum install -y mariadb-devel

接下来配置文件:在相应的配置文件中添加对应命令
4:

sudo vim /etc/my.cnf.d/client.cnf


# These two groups are read by the client library
# Use it for options that affect all clients, but not the server
#
[client]
# 新增下边一行配置,设置客户端默认字符集为utf8
default-character-set = utf8
# This group is not read by mysql client library,
# If you use the same .cnf file for MySQL and MariaDB,
# use it for MariaDB-only client options
[client-mariadb]

5:

sudo vim /etc/my.cnf.d/mysql-clients.cnf

# These groups are read by MariaDB command-line tools
# Use it for options that affect only one utility
#
[mysql]
# 新增配置
default-character-set = utf8
[mysql_upgrade]
[mysqladmin]
[mysqlbinlog]
[mysqlcheck]
[mysqldump]
[mysqlimport]
[mysqlshow]
[mysqlslap]

6:

sudo vim /etc/my.cnf.d/server.cnf

# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
[mysqld]
# 新增以下四行配置
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8
sql-mode = TRADITIONAL
# this is only for embedded server
[embedded]
# This group is only read by MariaDB-5.5 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mysqld-5.5]
# These two groups are only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
[mariadb-5.5]

⭐️
启动:

启动服务:

sudo systemctl start mariadb

设置服务开启自启动:

systemctl enable mariadb

查看服务状态:

systemctl status mariadb

测试连接

mysql -uroot
结果:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 190
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值