mariadb(mysql)的安装
生活随笔
收集整理的這篇文章主要介紹了
mariadb(mysql)的安装
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
vim /etc/yum.repos.d/MariaDB.repo 添加repo倉庫配置內(nèi)容 [mariadb] name=MariaDB baseurl=http://yum.mariadb.org/10.1/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
2 一條命令安裝官方的最新版本mariadb數(shù)據(jù)庫
yum install MariaDB-server MariaDB-client -y?安裝完成:
?3 由于官方鏈接可能會很慢,我們上課教學就用阿里云的源下載5.x的版本
yum install mariadb-server mariadb -y4 啟動mariadb數(shù)據(jù)庫
systemctl start mariadb 查看啟動的端口號詳情:netstat -tunlp #查看端口使用情況5 確保mariadb服務(wù)器啟動后,執(zhí)行命令初始化
mysql_secure_installation6 進入mysql,創(chuàng)建一個庫和一個表
mysql -u root -p 進入數(shù)據(jù)庫創(chuàng)建一個表格:
create table s1(name varchar(20),age int(32));往表格里面插入數(shù)據(jù):
insert into s1(name,age) values("張三“,12);7 發(fā)現(xiàn)不支持中文
desc # 查看數(shù)據(jù)庫編碼信息 show create database qishi2_haohaio show create table zhuanqq8 停止mariadb服務(wù)
systemctl stop mariadb9 修改配置文件,使mariadb支持中文
vim /etc/my.cnf 添加以下配置文件 [mysqld] character-set-server=utf8 collation-server=utf8_general_ci log-error=/var/log/mysqld.log [client] default-character-set=utf8 [mysql] default-character-set=utf810 啟動mariadb服務(wù)
systemctl start mariadb代表已經(jīng)啟動數(shù)據(jù)庫:
11 再進入mysql, 發(fā)現(xiàn)之前已經(jīng)被創(chuàng)建的中文數(shù)據(jù)不會被修改,所以,我們要把之前的亂碼中文數(shù)據(jù)刪除掉,重新再創(chuàng)建
刪除數(shù)據(jù)庫:drop database xmk;重新創(chuàng)建數(shù)據(jù)庫:并創(chuàng)建表
create database day; 創(chuàng)建表:create table test(name varchar(32),age int(18));插入數(shù)據(jù):并查看數(shù)據(jù)格式:MariaDB [day]> insert into test(name,age) value("張三",32); Query OK, 1 row affected (0.00 sec)MariaDB [day]> select * from test; +--------+------+ | name | age | +--------+------+ | 張三 | 32 | +--------+------+ 1 row in set (0.00 sec)MariaDB [day]>注意: 所以我們在一開始安裝mariadb時,就要將配置文件改為支持中文編碼的狀態(tài)?
轉(zhuǎn)載于:https://www.cnblogs.com/one-tom/p/10736492.html
總結(jié)
以上是生活随笔為你收集整理的mariadb(mysql)的安装的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python基础入门教程:使用 Pyth
- 下一篇: Redis分布式锁(Redlock官方文