MySQL/mariadb/centos安装:修订间差异
来自康健生活
| 第67行: | 第67行: | ||
default-character-set=utf8</syntaxhighlight>}} | default-character-set=utf8</syntaxhighlight>}} | ||
{{shc|<syntaxhighlight lang="bash"> | {| class="wikitable" | ||
|- | |||
| || {{shc|<syntaxhighlight lang="bash"> | |||
systemctl restart mariadb</syntaxhighlight>}} | systemctl restart mariadb</syntaxhighlight>}} | ||
|- | |||
MariaDB 查看字符集 | | MariaDB 查看字符集 || {{shc|<syntaxhighlight lang="mysql"> | ||
{{shc|<syntaxhighlight lang="mysql"> | |||
show variables like "%character%";show variables like "%collation%";</syntaxhighlight>|mysql>}} | show variables like "%character%";show variables like "%collation%";</syntaxhighlight>|mysql>}} | ||
|- | |||
创建用户命令 | | 创建用户命令 || {{shc|<syntaxhighlight lang="mysql"> | ||
{{shc|<syntaxhighlight lang="mysql"> | |||
create user username@localhost identified by 'password';</syntaxhighlight>|mysql>}} | create user username@localhost identified by 'password';</syntaxhighlight>|mysql>}} | ||
|- | |||
直接创建用户并授权的命令 | | 直接创建用户并授权的命令 || {{shc|<syntaxhighlight lang="mysql"> | ||
{{shc|<syntaxhighlight lang="mysql"> | |||
grant all on *.* to username@localhost indentified by 'password';</syntaxhighlight>|mysql>}} | grant all on *.* to username@localhost indentified by 'password';</syntaxhighlight>|mysql>}} | ||
|- | |||
授予外网登陆权限 | | 授予外网登陆权限 || {{shc|<syntaxhighlight lang="mysql"> | ||
{{shc|<syntaxhighlight lang="mysql"> | |||
grant all privileges on *.* to username@'%' identified by 'password';</syntaxhighlight>|mysql>}} | grant all privileges on *.* to username@'%' identified by 'password';</syntaxhighlight>|mysql>}} | ||
|- | |||
授予权限并且可以授权 | | 授予权限并且可以授权 || {{shc|<syntaxhighlight lang="mysql"> | ||
{{shc|<syntaxhighlight lang="mysql"> | |||
grant all privileges on *.* to username@'hostname' identified by 'password' with grant option;</syntaxhighlight>|mysql>}} | grant all privileges on *.* to username@'hostname' identified by 'password' with grant option;</syntaxhighlight>|mysql>}} | ||
|} | |||
2020年3月26日 (四) 12:28的最新版本
安装
搜索 MariaDB 现有的包
rpm -qa | grep mariadb
删除 MariaDB 现有的包
rpm -e --nodeps mariadb-*
或者
yum remove
创建MariaDB.repo
vi /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.2.4 CentOS repository list - created 2017-05-05 16:13 UTC # http://downloads.mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.2.4/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
yum -y install mariadb MariaDB-server MariaDB-client
systemctl start mariadb
systemctl enable mariadb
| 标题文字 | 标题文字 |
|---|---|
| systemctl start mariadb | 启动服务 |
| systemctl enable mariadb | 设置开机启动 |
| systemctl restart mariadb | 重新启动 |
| systemctl stop mariadb.service | 停止MariaDB |
| 示例 | 示例 |
进行MariaDB的相关简单配置
mysql_secure_installation
配置 MariaDB 的字符集
/etc/my.cnf
my.cnf
[mysqld]
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
client.cnf
[client]
default-character-set=utf8
/etc/my.cnf.d/mysql-clients.cnf
mysql-clients.cnf
[mysql]
default-character-set=utf8
systemctl restart mariadb
| |
| MariaDB 查看字符集 | show variables like "%character%";show variables like "%collation%";
|
| 创建用户命令 | create user username@localhost identified by 'password';
|
| 直接创建用户并授权的命令 | grant all on *.* to username@localhost indentified by 'password';
|
| 授予外网登陆权限 | grant all privileges on *.* to username@'%' identified by 'password';
|
| 授予权限并且可以授权 | grant all privileges on *.* to username@'hostname' identified by 'password' with grant option;
|
No categories