linux安装mysql的分支mariadb

1.配置官方的mariadb的yum源,手动建立 mariadb.repo仓库文件mysql

而后写入以下内容
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1linux

2.根据操做系统的不一样版本,centos采用yum安装指令,ubantu采用apt-get指令安装:sql

从官网安装:apt-get install MariaDB-server MariaDB-client -y数据库

若是中途断网,或者安装失败,能够先移除配置文件:rm -rf /etc/repos.d/Mariadb.repowindows

而后清空缓存:apt-get clean all centos

3.安装完成后,启动mariadb服务端:缓存

systemctl  start/stop/restart/stats  mariadb服务器

systemctl  enable  mariadb    开机自启动ide

.mysql初始化
mysql_secure_installation 这条命令能够初始化mysql,删除匿名用户,设置root密码等等....编码

设置mysql的中文编码支持,修改/etc/my.cnf
4.vi /etc/my.cnf
在[mysqld]中添加参数,使得mariadb服务端支持中文
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
2.重启mariadb服务,读取my.cnf新配置
systemctl restart mariadb
3.登陆数据库,查看字符编码
mysql -uroot -p

输入 \s 查看编码

********************************************************************

 

mysql经常使用命令
desc 查看表结构
create database 数据库名
create table 表名
show create database 库名 查看如何建立db的
show create table 表名; 查看如何建立table结构的

 

#修改mysql的密码
set password = PASSWORD('redhat');

#建立mysql的普通用户,默认权限很是低
create user yining@'%' identified by 'yiningzhenshuai';

#查询mysql数据库中的用户信息
use mysql;
select host,user,password from user;

***********************************************************************************************

给用户添加权限命令
grant all privileges on *.* to 帐户@主机名    对全部库和全部表受权全部权限

grant all privileges on *.* to yining@'%'; 给yining用户授予全部权限

flush privileges; 刷新受权表

授予远程登陆的权限命令 (root不能远程登陆的问题??)
grant all privileges on *.* to yining@'%'; 给yining用户授予全部权限


grant all privileges on *.* to root@'%' identified by 'redhat'; #给与root权限授予远程登陆的命令


此时能够在windows登陆linux的数据库

mysql -uyining -p -h 服务器的地址 链接服务器的mysql

相关文章
相关标签/搜索