MySQL/mariadb/centos安装:修订间差异
来自康健生活
创建页面,内容为“== 安装 == 搜索 MariaDB 现有的包 <syntaxhighlight lang="bash"> rpm -qa | grep mariadb</syntaxhighlight> 删除 MariaDB 现有的包 <syntaxhighlight lang="ba…” |
|||
| (未显示同一用户的3个中间版本) | |||
| 第45行: | 第45行: | ||
mysql_secure_installation</syntaxhighlight> | mysql_secure_installation</syntaxhighlight> | ||
=== 配置 MariaDB 的字符集 === | === 配置 MariaDB 的字符集 === | ||
/etc/my.cnf | |||
{{hc|my.cnf|<syntaxhighlight lang="mysql"> | |||
[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</syntaxhighlight>}} | |||
/etc/my.cnf.d/client.cnf | |||
{{hc|client.cnf|<syntaxhighlight lang="mysql"> | |||
[client] | |||
default-character-set=utf8</syntaxhighlight>}} | |||
/etc/my.cnf.d/mysql-clients.cnf | |||
{{hc|mysql-clients.cnf|<syntaxhighlight lang="mysql"> | |||
[mysql] | |||
default-character-set=utf8</syntaxhighlight>}} | |||
{| class="wikitable" | |||
|- | |||
| || {{shc|<syntaxhighlight lang="bash"> | |||
systemctl restart mariadb</syntaxhighlight>}} | |||
|- | |||
| MariaDB 查看字符集 || {{shc|<syntaxhighlight lang="mysql"> | |||
show variables like "%character%";show variables like "%collation%";</syntaxhighlight>|mysql>}} | |||
|- | |||
| 创建用户命令 || {{shc|<syntaxhighlight lang="mysql"> | |||
systemctl restart mariadb | create user username@localhost identified by 'password';</syntaxhighlight>|mysql>}} | ||
|- | |||
| 直接创建用户并授权的命令 || {{shc|<syntaxhighlight lang="mysql"> | |||
mysql> show variables like "%character%";show variables like "%collation%"; | grant all on *.* to username@localhost indentified by 'password';</syntaxhighlight>|mysql>}} | ||
|- | |||
| 授予外网登陆权限 || {{shc|<syntaxhighlight lang="mysql"> | |||
创建用户命令 | grant all privileges on *.* to username@'%' identified by 'password';</syntaxhighlight>|mysql>}} | ||
|- | |||
mysql>create user username@localhost identified by 'password'; | | 授予权限并且可以授权 || {{shc|<syntaxhighlight lang="mysql"> | ||
直接创建用户并授权的命令 | grant all privileges on *.* to username@'hostname' identified by 'password' with grant option;</syntaxhighlight>|mysql>}} | ||
|} | |||
mysql>grant all on *.* to username@localhost indentified by 'password'; | |||
授予外网登陆权限 | |||
mysql>grant all privileges on *.* to username@'%' identified by 'password'; | |||
授予权限并且可以授权 | |||
mysql>grant all privileges on *.* to username@'hostname' identified by 'password' with grant option; | |||