Mysql常规安装配置设置(linux)

MySQL的安装与配置

"在此仅作记录使用,若能帮助别人也是欢喜"

安装

<Kali linux已经提前安装好了mysql>

若要安装mysql,前往一篇教程(感谢提供注明引用!):https://www.cnblogs.com/fanshudada/p/9781794.html

配置

首先进入mysql目录

 1 root@cryptkid:~# cd /etc/mysql/ 

1 root@cryptkid:/etc/mysql# ls
2 conf.d      debian-start  mariadb.conf.d  my.cnf.fallback
3 debian.cnf  mariadb.cnf   my.cnf

然后打开my.conf文件(在此使用的是leafpad)

打开后显示如下:

 1 # The MariaDB configuration file
 2 #
 3 # The MariaDB/MySQL tools read configuration files in the following order:
 4 # 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
 5 # 2. "/etc/mysql/conf.d/*.cnf" to set global options.
 6 # 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
 7 # 4. "~/.my.cnf" to set user-specific options.
 8 #
 9 # If the same option is defined multiple times, the last one will apply.
10 #
11 # One can use all long options that the program supports.
12 # Run program with --help to get a list of available options and with
13 # --print-defaults to see which it would actually understand and use.
14 
15 #
16 # This group is read both both by the client and the server
17 # use it for options that affect everything
18 #
19 [client-server]
20 # Import all .cnf files from configuration directory
21 !includedir /etc/mysql/conf.d/
22 !includedir /etc/mysql/mariadb.conf.d/

再然后我们添加几项配置内容:

1 [client]  
2 default-character-set = utf8  
3 
4 [mysqld]  
5 default-storage-engine = INNODB  
6 character-set-server = utf8  
7 collation-server = utf8_general_ci

注意要#即注释掉[client-server],更改完成后如下(红色为更改添加的内容):

 1 # The MariaDB configuration file
 2 #
 3 # The MariaDB/MySQL tools read configuration files in the following order:
 4 # 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
 5 # 2. "/etc/mysql/conf.d/*.cnf" to set global options.
 6 # 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
 7 # 4. "~/.my.cnf" to set user-specific options.
 8 #
 9 # If the same option is defined multiple times, the last one will apply.
10 #
11 # One can use all long options that the program supports.
12 # Run program with --help to get a list of available options and with
13 # --print-defaults to see which it would actually understand and use.
14 
15 #
16 # This group is read both both by the client and the server
17 # use it for options that affect everything
18 #
19 #[client-server]
20 [client]  
21 default-character-set = utf8  
22 
23 [mysqld]  
24 default-storage-engine = INNODB  
25 character-set-server = utf8  
26 collation-server = utf8_general_ci
27 # Import all .cnf files from configuration directory
28 !includedir /etc/mysql/conf.d/
29 !includedir /etc/mysql/mariadb.conf.d/

保存退出!

使用

打开终端输入:

1 root@cryptkid:~# mysql -u root

显示:

1 Welcome to the MariaDB monitor.  Commands end with ; or \g.
2 Your MariaDB connection id is 53
3 Server version: 10.3.20-MariaDB-1 Debian buildd-unstable
4 
5 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
6 
7 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
8 
9 MariaDB [(none)]>

即可使用。

 

posted @ 2020-02-09 16:15  长风Studio  阅读(488)  评论(0编辑  收藏  举报