SQL_CentOS 7下安装MariaDB,sql_centosmariadb
进入root模式
$ su
①安装
安装MariaDB服务
# yum install -y mariadb-server
安装MariaDB命令行客户端
# yum install -y mariadb
安装 MariaDB C library
# yum install -y mariadb-libs
安装 mariadb 开发包
# yum install -y mariadb-devel
②更改配置
# vim /etc/my.cnf.d/client.cnf
[client] 下加上如下内容
default-character-set=utf8
# vim /etc/my.cnf.d/mysql-clients.cnf
[mysql] 下加上如下内容
default-character-set=utf8
# vim /etc/my.cnf.d/server.cnf
[mysqld] 下加上如下内容
collation-server = utf8_general_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
sql-mode = TRADITIONAL
③启动
启动服务
# systemctl start mariadb
设置服务开机自动启动
# systemctl enable mariadb
查看服务状态
# systemctl status mariadb
输出如下,注意到 Active 状态为 active (running)
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since 一 2018-12-10 10:56:33 CST; 6 days ago
Main PID: 32328 (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─32328 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─32564 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-d...
12月 10 10:56:31 aliyun mariadb-prepare-db-dir[32250]: MySQL manual for more instructions.
12月 10 10:56:31 aliyun mariadb-prepare-db-dir[32250]: Please report any problems at ht...a
12月 10 10:56:31 aliyun mariadb-prepare-db-dir[32250]: The latest information about Mar....
12月 10 10:56:31 aliyun mariadb-prepare-db-dir[32250]: You can find additional informat...:
12月 10 10:56:31 aliyun mariadb-prepare-db-dir[32250]: http://dev.mysql.com
12月 10 10:56:31 aliyun mariadb-prepare-db-dir[32250]: Consider joining MariaDB's stron...:
12月 10 10:56:31 aliyun mariadb-prepare-db-dir[32250]: https://mariadb.org/get-involved/
12月 10 10:56:31 aliyun mysqld_safe[32328]: 181210 10:56:31 mysqld_safe Logging to '/v...'.
12月 10 10:56:31 aliyun mysqld_safe[32328]: 181210 10:56:31 mysqld_safe Starting mysql...ql
12月 10 10:56:33 aliyun systemd[1]: Started MariaDB database server.
Hint: Some lines were ellipsized, use -l to show in full.
④测试连接
使用命令行客户端尝试连接
# mysql -u root
输出如下
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 100
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
查看MariaDB版本号
MariaDB [(none)]> select version();
输出如下
+----------------+
| version() |
+----------------+
| 5.5.60-MariaDB |
+----------------+
1 row in set (0.00 sec)
查看字符集配置
MariaDB [(none)]> show variables like '%char%';
输出如下
+--------------------------+----------------------------+
| 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)
⑤设置密码
退出MariaDB
MariaDB [(none)]> exit
设置密码
# mysql_secure_installation
有Y/N时, 一律选择Y
出现下述内容时, 设置密码
New password:
出现下述内容时, 再次输入刚才输入的密码
Re-enter new password:
⑥使用命令行客户端再次连接(带密码)
# mysql -u root -p
随后输入刚设置的密码
输入如下
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 101
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
完成!
本站文章为和通数据库网友分享或者投稿,欢迎任何形式的转载,但请务必注明出处.
同时文章内容如有侵犯了您的权益,请联系QQ:970679559,我们会在尽快处理。