日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux mariadb

發(fā)布時間:2025/5/22 linux 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux mariadb 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

https://www.linuxidc.com/Linux/2016-03/128880.htm

?-- sql 導(dǎo)入

接著輸入你所導(dǎo)入到Centos下的數(shù)據(jù)庫文Student.sql文件的位置
例如:當(dāng)前目錄下打開mariadb? 直接導(dǎo)入sql 文件
mysql>source /usr/database.sql;

?

-- 上傳命令

先使用命令?yum install -y lrzsz

rz 上傳? ? 或者直接拖動

sz 要下的文件 回車?

1、安裝MariaDB

安裝命令

yum -y install mariadb mariadb-server

?

?

閑置已久的空間環(huán)境配置忘得差不多了,今天得空整理,重置了磁盤重新搭建環(huán)境,首先在CentOS?7.0安裝MariaDB的數(shù)據(jù)庫,在這里記錄下安裝過程,以便以后查看。

1、安裝MariaDB

安裝命令

yum -y install mariadb mariadb-server

安裝完成MariaDB,首先啟動MariaDB

systemctl start mariadb

設(shè)置開機啟動

systemctl enable mariadb

接下來進(jìn)行MariaDB的相關(guān)簡單配置

mysql_secure_installation

首先是設(shè)置密碼,會提示先輸入密碼

Enter current password for root (enter for none):<–初次運行直接回車

設(shè)置密碼

Set root password? [Y/n]?<– 是否設(shè)置root用戶密碼,輸入y并回車或直接回車
New password:?<– 設(shè)置root用戶的密碼
Re-enter new password:?<– 再輸入一次你設(shè)置的密碼

其他配置

Remove anonymous users? [Y/n]?<– 是否刪除匿名用戶,回車

Disallow root login remotely? [Y/n]?<–是否禁止root遠(yuǎn)程登錄,回車,

Remove test database and access to it? [Y/n]?<– 是否刪除test數(shù)據(jù)庫,回車

Reload privilege tables now? [Y/n]?<– 是否重新加載權(quán)限表,回車

初始化MariaDB完成,接下來測試登錄

mysql -uroot -ppassword

完成。

?

2、配置MariaDB的字符集

文件/etc/my.cnf

vi /etc/my.cnf

在[mysqld]標(biāo)簽下添加

init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAMES utf8' character-set-server=utf8 collation-server=utf8_unicode_ci skip-character-set-client-handshake

文件/etc/my.cnf.d/client.cnf

vi /etc/my.cnf.d/client.cnf

在[client]中添加

default-character-set=utf8

文件/etc/my.cnf.d/mysql-clients.cnf

vi /etc/my.cnf.d/mysql-clients.cnf

在[mysql]中添加

default-character-set=utf8

?全部配置完成,重啟mariadb

systemctl restart mariadb

之后進(jìn)入MariaDB查看字符集

mysql> show variables like "%character%";show variables like "%collation%";

顯示為


+--------------------------+----------------------------+
| Variable_name? ? ? ? ? ? | Value? ? ? ? ? ? ? ? ? ? ? |
+--------------------------+----------------------------+
| character_set_client? ? | utf8? ? ? ? ? ? ? ? ? ? ? |
| character_set_connection | utf8? ? ? ? ? ? ? ? ? ? ? |
| character_set_database? | utf8? ? ? ? ? ? ? ? ? ? ? |
| character_set_filesystem | binary? ? ? ? ? ? ? ? ? ? |
| character_set_results? ? | utf8? ? ? ? ? ? ? ? ? ? ? |
| character_set_server? ? | utf8? ? ? ? ? ? ? ? ? ? ? |
| character_set_system? ? | utf8? ? ? ? ? ? ? ? ? ? ? |
| character_sets_dir? ? ? | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

+----------------------+-----------------+
| Variable_name? ? ? ? | Value? ? ? ? ? |
+----------------------+-----------------+
| collation_connection | utf8_unicode_ci |
| collation_database? | utf8_unicode_ci |
| collation_server? ? | utf8_unicode_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)

字符集配置完成。

?

3、添加用戶,設(shè)置權(quán)限

創(chuàng)建用戶命令

mysql>create user username@localhost identified by 'password';

直接創(chuàng)建用戶并授權(quán)的命令

mysql>grant all on *.* to username@localhost indentified by 'password';

授予外網(wǎng)登陸權(quán)限?

mysql>grant all privileges on *.* to username@'%' identified by 'password';

授予權(quán)限并且可以授權(quán)

mysql>grant all privileges on *.* to username@'hostname' identified by 'password' with grant option;

簡單的用戶和權(quán)限配置基本就這樣了。

其中只授予部分權(quán)限把?其中?all?privileges或者all改為select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file其中一部分。

?

安裝完成MariaDB,首先啟動MariaDB

systemctl start mariadb

設(shè)置開機啟動

systemctl enable mariadb

mysql -u root -p

[root@instance-mg3698mm ~]# systemctl restart mariadb;
[root@instance-mg3698mm ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.60-MariaDB MariaDB Server

?

?

-- 遠(yuǎn)程授權(quán)訪問權(quán)限

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '1' WITH GRANT OPTION;

轉(zhuǎn)載于:https://www.cnblogs.com/javajetty/p/9655587.html

總結(jié)

以上是生活随笔為你收集整理的linux mariadb的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。